- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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,
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
My guess, your X axis values 0 to 2 but you have formatted values may be causing the issue. Your original code didn't have a format so if that was actually in the code it may be part of the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
69
70 ods graphics / attrpriority=none;
71 proc sgplot data=want_means aspect=1 noautolegend;
72 styleattrs datasymbols=(diamondfilled squarefilled)
73 datacontrastcolors=(navy magenta) datalinepatterns=(solid);
74 series x=timepoint y=promis_pain_interference_Mean / lineattrs=(thickness=3px)
75 markers markerattrs=(size=12pt);
76 yaxis
77 values=(4 to 20 by 1) label='PROMIS Pain Interference Score (Mean)'
78 labelattrs=(size=16pt weight=bold color=gray33)
79 valueattrs=(size=16pt weight=bold color=gray33)
80 offsetmin=0 offsetmax=0 grid minor minorcount=3;
81 xaxis
82 values=(0 to 2 by 1) label='Timepoint'
83 labelattrs=(size=16pt weight=bold color=gray33)
84 valueattrs=(size=16pt weight=bold color=gray33)
85 offsetmin=0 offsetmax=0 grid minor minorcount=3;
86 run;
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.11 seconds
user cpu time 0.05 seconds
system cpu time 0.01 seconds
memory 8307.78k
OS Memory 34604.00k
Timestamp 10/27/2021 05:33:32 PM
Step Count 207 Switch Count 1
Page Faults 0
Page Reclaims 1337
Page Swaps 0
Voluntary Context Switches 153
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 512
NOTE: Some of the tick values have been thinned.
NOTE: There were 3 observations read from the data set WORK.WANT_MEANS.
87 quit;
88 ODS HTML CLOSE;
89 ODS LISTING;
90
91 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
101
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Log:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output features.
69
70 Proc freq data=kb.data_01 ORDER=FREQ;
71 /* where timepoint = "fu_1_arm_2"; */
72 /* by timepoint ; */
73 table
74 /* source */
75 /* location_pn */
76 /* oral_meds_yn */
77 /* top_meds_yn */
78 /* aes_yn */
79 /* aes_sev */
80 /* aes_hc */
81 /* aes_acn */
82 /* aes_out */
83 dose
84 freq
85 /* adherence */
86 satisfaction
87 /* saf_effec */
88 / plots=(freqplot);
89
90 /* FORMAT advise yes_no_fmt.; */
91 TITLE "Descriptive Statistics for Categorical Measures";
92 ods output onewayfreq=want_freq;
93 RUN;
WARNING: Output 'onewayfreq' was not created. Make sure that the output object name, label, or path is spelled correctly. Also,
verify that the appropriate procedure options are used to produce the requested output object. For example, verify that
the NOPRINT option is not used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your graphs shouldn't have been affected as that's the want_means data set though.
You didn't show the log for the graph portion though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
My guess, your X axis values 0 to 2 but you have formatted values may be causing the issue. Your original code didn't have a format so if that was actually in the code it may be part of the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.