Is there a way to graph means and proportions derived from PROC MEANS and PROC FREQ across 3 time points (var = timepoint)?
PROC MEANS DATA=kb.data_01 maxdec=1;
VAR
promis_pain_intensity
promis_pain_interference
;
CLASS timepoint;
TITLE "Descriptive Statistics for Continuous Measures";
RUN;
PROC FREQ DATA=kb.data_01 ORDER=FREQ;
/* by timepoint ; */
TABLE
aes_yn
dose
adherence
satisfaction
/ PLOTS=(freqplot);
TITLE "Descriptive Statistics for Categorical Measures";
RUN;
Also,
First you'd use PROC MEANS and FREQ to save the output to a data set. Depending on exactly what you want you may be able to plot it directly from the raw data or need to pre-summarize the data.
Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...
I've included examples below for you.
If your variables are binary then you can also use the fact that the average of a 0/1 variable is the percentage or proportion of the variable.
PROC MEANS DATA=kb.data_01 maxdec=1;
VAR
promis_pain_intensity
promis_pain_interference
;
CLASS timepoint;
TITLE "Descriptive Statistics for Continuous Measures";
ods output summary = want_means;
RUN;
PROC FREQ DATA=kb.data_01 ORDER=FREQ;
/* by timepoint ; */ TABLE
aes_yn
dose
adherence
satisfaction
/ PLOTS=(freqplot);
TITLE "Descriptive Statistics for Categorical Measures";
ods output onewayfreq=want_freq;
RUN;
Graphing it may be harder, depends on exactly what you're looking for.
Here's some examples of common graph types. There are fully worked examples here so you can follow the code/output together.
https://robslink.com/SAS/ods2/aaaindex.htm
If you have more specific questions please feel free to ask!
@_maldini_ wrote:
Is there a way to graph means and proportions derived from PROC MEANS and PROC FREQ across 3 time points (var = timepoint)?
PROC MEANS DATA=kb.data_01 maxdec=1; VAR promis_pain_intensity promis_pain_interference ; CLASS timepoint; TITLE "Descriptive Statistics for Continuous Measures"; RUN;
PROC FREQ DATA=kb.data_01 ORDER=FREQ; /* by timepoint ; */
TABLE aes_yn dose adherence satisfaction / PLOTS=(freqplot); TITLE "Descriptive Statistics for Categorical Measures"; RUN;Also,
This is great. Thank you!
A few other questions. The syntax below seems to work, but I can't seem to figure out the proc sgplot syntax.
Proc means data=kb.data_01 maxdec=1; var age promis_pain_intensity promis_pain_interference ; class timepoint; title "Descriptive Statistics for Continuous Measures"; ods output summary = want_means; run; proc print data=want_means; var promis_pain_interference_Mean promis_pain_intensity_Mean; by timepoint; run;
I've done my best to adapt the code from the desired robslink.com page, but the means aren't plotted on the graph (see below).
ods graphics / attrpriority=none; proc sgplot data=want_means aspect=1 noautolegend; styleattrs datasymbols=(diamondfilled squarefilled) datacontrastcolors=(navy magenta) datalinepatterns=(solid); series x=timepoint y=promis_pain_interference_Mean / lineattrs=(thickness=3px) markers markerattrs=(size=12pt); yaxis values=(4 to 20 by 1) label='PROMIS Pain Interference Score (Mean)' labelattrs=(size=16pt weight=bold color=gray33) valueattrs=(size=16pt weight=bold color=gray33) offsetmin=0 offsetmax=0 grid minor minorcount=3; xaxis values=(0 to 2 by 1) label='Timepoint' labelattrs=(size=16pt weight=bold color=gray33) valueattrs=(size=16pt weight=bold color=gray33) offsetmin=0 offsetmax=0 grid minor minorcount=3; run; quit; ODS HTML CLOSE; ODS LISTING;
Any clues in my syntax? Also, do you know how I would add SD bars?
Thanks again!
It looks like the problem lies in the commented-out syntax. When I run it w/o specifying details about the x and y axis, I get this graph:
proc sgplot data=want_means;
series x=timepoint y=promis_pain_intensity_Mean / lineattrs=(thickness=3px)
markers markerattrs=(size=10pt);
/* yaxis */
/* values=(3 to 15 by 1) label='PROMIS Pain Intensity Score (Mean)' */
/* labelattrs=(size=14pt weight=bold color=gray33) */
/* valueattrs=(size=14pt weight=bold color=gray33) */
/* offsetmin=0 offsetmax=0 grid minor minorcount=1; */
/* */
/* xaxis */
/* values=(0 to 2 by 1) label='Timepoint' */
/* labelattrs=(size=14pt weight=bold color=gray33) */
/* valueattrs=(size=14pt weight=bold color=gray33) */
/* offsetmin=0 offsetmax=0 grid minor minorcount=1; */
format Timepoint $timepoint_.;
run;
Maybe you could point me in the direction of some alternative syntax for customizing the axes?
Thanks!
You were correct. It was a format issue. The problem is resolve and I will accept this as the solution. Thanks!
Is there an option for adding the value of the data point to the graph? I can't seem to find one in the documentation.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.