Hi Everyone,
I have question on Box plot displaying all four variables in one page without multiple by pages
Below is the code I am using by proc sgplot to produce box plot: I don't want use site in by group if I use, I am getting the figure in three different pages . so I want to display all sites in one page without using by group . In one box plot I should see the aval results by treatment , by visit and by site in one page without multiple pages. Is there any other option i can use to display all variables in one page
data x;
infile datalines delimiter=',';
input site$ subjid$ aval$ visit$ trt$;
datalines;
101 , 101-011 , 10 , week0 , 1
101 , 101-012 , 15 , week8 , 2
101 , 101-013 , 80 , week12 , 3
102 , 102-011 , 23 , week0 , 1
102 , 102-012 , 24 , week8 , 2
102 , 102-013 , 35 , week12 , 3
103 , 103-011 , 47 , week0 , 1
103 , 103-012 , 46 , week8 , 2
103 , 103-013 , 28 , week12 , 3
;
run;
proc sgplot data=adimmuno;
by site;
format trt01pn trt1f. ;
vbox aval / category=trt Group=visit
xaxis label='Treatment' valueattrs=(size=8) ;
yaxis values=(0 to 12000 by 1000) label='Analysis Value' ;
run;
Since even changing the proc sgplot code to use your example data set the code does not run: Variable trt01pn not in data, format specified not provided, no semicolon ending the VBOX statement and the requirement that the VBOX variable be numeric and data not sorted by SITE. I suggest that you revisit your example data set and provide a better match to the code.
The data step also doesn't run as there are other characters besides spaces and commas in the data lines, possibly because of pasting into the main message window. The message windows on this forum will reformat text and sometimes that changes pasted text enough that code will not run. Paste code into a text box opened on the forum with the </> icon that appears above the message window.
Your Y axis statement also renders the Aval values shown, once the datalines are "corrected", pretty compact.
It appears that you would need to create a composite variable to hold the values of site and visit. I think. I am not sure exactly what you want.
Is this even close:
data x; infile datalines delimiter=','; input site$ subjid$ aval visit$ trt$; newcat = catx(' ',site,visit); datalines; 101,101-011,10,week0,1 101,101-012,15,week8,2 101,101-013,80,week12,3 102,102-011,23,week0,1 102,102-012,24,week8,2 102,102-013,35,week12,3 103,103-011,47,week0,1 103,103-012,46,week8,2 103,103-013,28,week12,3 ; run; proc sgplot data=x; /*by site;*/ /*format trt01pn trt1f. ;*/ vbox aval / category=newcat Group=trt; xaxis label='Treatment' ; /*yaxis values=(0 to 12000 by 1000) label='Analysis Value' ;*/ run;
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.