This is related to my previous question : Escape characters interpreted as array in SAS
I have managed to create the variable with special character (despite not a good practice, this is required).
Now I am trying to plot the respective variable using sgplot, but again having a difficulty to fetch the Age(years) variable , as it contains the special character of array ( )
data have;
input Name $ Gender $ Age_years Health $;
datalines;
Dino male 6 sick
Rita female 5 healthy
Aurora female 4 healthy
Joko male 3 sick
;
run;
options validvarname=any;
data want;
set have;
'Age(years)'n=Age_years;
run;
options validvarname=any;
ods graphics / reset width=4in height=3in;
proc sgplot data=want noautolegend;
*Error occurs here*;
yaxistable Gender 'Age(years)'n /
labelattrs=GraphUnicodeText(weight=bold size=9pt)
labelhalign=center position=left location=outside;
*Error occurs here*;
scatter y='Age(years)'n x=Health;
xaxis offsetmin=0.1 offsetmax=1 label="Health Status"
labelattrs=GraphUnicodeText(weight=bold size=9pt) ;
yaxis offsetmax=0.1 display=none;
run;
In the above code, sgplot does not work because of the following line
yaxistable Gender 'Age(years)'n /
labelattrs=GraphUnicodeText(weight=bold size=9pt)
labelhalign=center position=left location=outside;
The aim is to display 'Age(years)' in the graph.
How can I allow the yaxistable of sgplot to read 'Age(years)' as a variable and display this correctly on the graph?
Age(years)for display purposes? Couldn't you just keep the variable asage_yearsand have it displayed asAge(years)by using a label? - user2877959LABEL=option of theyaxistablestatement. - user2877959