BookmarkSubscribeRSS Feed
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Hello,

 

Below is the code for the data I have. I am trying to create a line graph with 2 lines showing the qrt_yr on the x-axis and the on the y-axis the number of events but I need the sum of the events cst and bta. My code currently only shows a max of 1 in the graph when, for example, q1-2010 cst should show 3 events. Var1 and Var2 are binary variables, where a 1 indicates the event occurred. Any advice would be helpful. Thank you 

 

data have;
	input qrt_yr $ var1 var2;
	datalines;
	q1-2010 1 0
	q1-2010 1 0
	q1-2010 1 1
	q1-2010 0 0
	q2-2010 1 0
	q3-2010 1 0
	q4-2010 1 0
	q1-2011 1 0
	q2-2011 0 1
	q3-2011 1 1
	q4-2011 0 1
	q1-2012 1 0
	q2-2012 1 0
	q3-2012 1 0
	q3-2012 1 1
	q4-0212 1 1
	q1-2014 1 1
	q2-2014 1 1
	q3-2014 1 1
	q3-2014 1 1
	q4-2014 0 1
	;
run;

proc sgplot data= have; 
	series x= qrt_yr y= var1; 
	series x= qrt_yr y= var2;	
run; 
2 REPLIES 2
PaigeMiller
Diamond | Level 26

After creating data set HAVE, run PROC SUMMARY to get the sums, and then run PROC SGPLOT on the output created by PROC SUMMARY.

--
Paige Miller
GS2
Obsidian | Level 7 GS2
Obsidian | Level 7

Attached is my code for the proc summary. When I do this it returns the number of observations per quarter and year, I would like it to return the times var1=1 and the number of times var2=1 and plot both of those lines on a graph to see how they move in relationship to one another. Is there a way to modify this code to accomplish that. Thank you 

proc summary data= check8;
	class qrt_yr;
	var var1 var2;
	output out=check9;
run;

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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