Hello,
I am trying to turn the results from PROC FREQ into an overlapping line plot where each line is a different 'priority group' y axis is percentage of priority group who uses Patch out of total priority group and x axis is years (2003, 2010, 2011).
Priority Groups:
Hispanic
NH White
NH Black
NH Asian/PI
NH Indigenous
Patch: Yes , No, NoResponse
What I currently have
PROC FREQ DATA=HARMON_FINAL(WHERE=(SURYEAR<2014));
TABLES PRIORITY*SURYEAR*PATCH/ PLOTS=FREQPLOT;
run;
What it gives me a unique table for each priority group (for example Hispanic Group)What I want instead:
Dot graph with lines connecting the same priority group across all years
Percentage of patch 'yes' on Yaxis and
Survey Year on X axis
and 5 lines (one for each priority group)
Thanks for any advice.
Summarize the data and create an output data set to use in proc sgplot.
Look at this page for a very similar request. A proc freq example is towards the bottom.
You don't show how your Patch variable may be valued/coded but you would select the 'Yes' value in a where statement in proc sgplot as shown with your Patch variable.
The series statement has lots of options for setting lines using LINEATTRS=(pattern=dot ) for simple dotted line. There are 46 different line patterns available. You can set line thickness. With a group variable for your "priority group" values each line will default to a different appearance. I would start with that before adding additional options.
Summarize the data and create an output data set to use in proc sgplot.
Look at this page for a very similar request. A proc freq example is towards the bottom.
You don't show how your Patch variable may be valued/coded but you would select the 'Yes' value in a where statement in proc sgplot as shown with your Patch variable.
The series statement has lots of options for setting lines using LINEATTRS=(pattern=dot ) for simple dotted line. There are 46 different line patterns available. You can set line thickness. With a group variable for your "priority group" values each line will default to a different appearance. I would start with that before adding additional options.
Thank you! This is exactly what I needed.
My solution:
PROC FREQ DATA=HARMON_FINAL ;
TABLES PRIORITY*SURWAVE*PATCH/OUTPCT OUT=FREQOUT_PATCH;
RUN;
DATA PATCHUSE;
SET FREQOUT_PATCH;
IF SURWAVE=7 THEN DELETE;
IF PATCH~=1 THEN DELETE;
RUN;
PROC SGPLOT DATA=PATCHUSE;
TITLE "PATCH USE BY PRIORITY GROUP";
SCATTER X=SURWAVE Y=PCT_ROW /GROUP=PRIORITY;
SERIES X=SURWAVE Y=PCT_ROW /GROUP=PRIORITY;
XAXIS LABEL="SURVEY WAVE";
XAXIS TYPE=DISCRETE;
YAXIS LABEL="PERCENTAGE OF PARTICIPANTS WHO USED PATCH";
RUN;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.