BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Deanna_Payne
Obsidian | Level 7

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)Screen Shot 2022-03-31 at 3.59.07 PM.pngWhat 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.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-line-graph-showing-proportion-by-ag...

 

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

 

https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-line-graph-showing-proportion-by-ag...

 

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.

Deanna_Payne
Obsidian | Level 7

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;

Screen Shot 2022-03-31 at 5.32.51 PM.png

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 2 replies
  • 749 views
  • 0 likes
  • 2 in conversation