@MBlack732 wrote:
Perfect! Thank you!
I'm pretty new to SAS (first-year grad student), so I always get excited to see a log with no error messages!
Thank you, again!
And a different procedure:
proc summary data=have nway;
class subject;
var glucose;
output out=want (drop=_:) max= /autoname
;
run;
Proc summary will do a few more statistics than Proc Sql has available. Also if you have mulitiple variables to summarize you only need to add them to the VAR statement. The AUTONAME option creates variables with the statistic as a suffix to the original variable.
Another feature with class variables is the possibility of doing summaries based on different combinations of them. Without the NWAY statement you would get a summary overall across all subjects of the date. The drop statement removes a variable _type_ that would indicate which combination of the class variables a current output record would indicate.
Also with appropriate formats for the date variable you can get summaries grouped in many ways.
Example using somewhat modified data:
DATA homework2;
INPUT subject $ visit_date mmddyy8. glucose;
format visit_date date9.;
DATALINES;
1 06/14/16 113
1 05/21/16 107
1 08/17/16 98
1 12/01/16 110
2 03/21/18 118
2 04/04/18 106
2 01/23/18 117
;
RUN;
proc summary data=homework2 nway;
class subject visit_date;
format visit_date yyq6.;
var glucose ;
output out=want max= min= mean=/autoname;
run;
which would provide the max, min and mean value of glucose by calendar quarter. The more variables and statistics you want Proc Summary or Means becomes much more code efficient as you don't have to explicitly create the variable names and as I said previously, there are statistics such as quartiles, percentiles, interquartile range, range that SQL does not support.
... View more