BookmarkSubscribeRSS Feed
JDDowell
Fluorite | Level 6

Hello,

 

I'm trying to plot a series of the number of youth in a program over time. My dates are for a single month, but when I try to plot it my series keeps dropping down to zero for everyday after the 1st of the month, or at least that's what I think happening. 

 

Proc sgplot data=work.efc_pi;
series y='Number Of Youth'n x='Month of Service'n;
run;

 

Series Problem.PNG

 

Currently the date is formatted as Monyy5. is there a different format I need to convert it to in order to solve this problem?

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Pseudo code because we don't know what variable names you are using or the exact structure of your data set

 

proc sgplot data=work.efc_pi(where=(day('Month of Service'n)=1));
    series y='Number Of Youth'n x='Month of Service'n;
run;

 

--
Paige Miller
JDDowell
Fluorite | Level 6

I don't understand this reply, I'm sorry. Those are the names of my columns.

Data EFC_PI;
	set work.'efc costing data as of 9_1_2019'n;
	'Month of Service'n=MonthOfService;
	format 'Month Of Service'n monyy5.;
	'Gross Payment'n=Am_gross_pay_sum;
	'Program Index'n=ProgramIndex;
	'Number of Youth'n=N_Youth;
run;

I only changed the column names for the chart. 

PaigeMiller
Diamond | Level 26

@JDDowell wrote:

I don't understand this reply, I'm sorry. Those are the names of my columns.

I only changed the column names for the chart. 


We really need to see a portion of the actual data set you are using, so we can both be working from the exact same starting point, using the method referred to by @Reeza .

 

With regards to needle plots, if you want a series plot, a needle plot isn't really a replacement for a series plot.

--
Paige Miller
JDDowell
Fluorite | Level 6
data Example;
	Infile datalines dlm=',';
	input MonthOfService MonYY5. NumberOfYouth $ ProgramIndex $ Expenditure $;
	format MonthofService MonYY5.;
	datalines; 
JUL13,	6,	A1211,	57512.16
JUL13,	1,	A1236,	2867.5
JUL13,	2,	A1291,	8834
JUL13,	20,	A1292,	98601.88
JUL13,	3,	A1421,	410.98
JUL13,	7,	A1552,	21686.49
JUL13,	1,	A1841,	205.17
JUL13,	155,A1911,	179972.06
JUL13,	10,	A1912,	5253.34
JUL13,	44,	A1916,	17200.8
JUL13,	7,	A1917,	7545.48
JUL13,	8,	A1918,	4259.63
JUL13,	2,	A1957,	1249.02
JUL13,	3,	A1961,	3506.19
JUL13,	6,	A1962,	2617.05
JUL13,	2,	A1964,	1372.25
JUL13,	1,	A1971,	7.03
JUL13,	17,	A1975,	4398.16
JUL13,	23,	A1977,	4476.84
JUL13,	1,	A8811,	40
AUG13,	7,	A2111,	71842.76
AUG13,	2,	A2111,	8428.8
AUG13,	23,	A2111,	126240.33
AUG13,	1,	A2129,	1239
AUG13,	167,A2106,	191061.43
AUG13,	14,	A2106,	7061.28
AUG13,	46,	A2109,	18020.98
AUG13,	7,	A2124,	7711.68
AUG13,	5,	A2126,	903.72
AUG13,	1,	A2106,	1867.5
AUG13,	1,	A2129,	857.15
AUG13,	5,	A2115,	6404.33
AUG13,	10,	A2115, 3605.26
AUG13,	2,	A2114, 1372.25
AUG13,	16,	A2115,	3598.64
AUG13,	28,	A2115,	5182.93
SEP13,	7,	A2111,	71842.76
SEP13,	1,	A2111,	5232
SEP13,	23,	A2111,	119037.69
SEP13,	170,	A2106,	186012.25
SEP13,	19,	A2106,	10104.19
SEP13,	46,	A2109,	18979.5
SEP13,	7,	A2124,	6747.72
SEP13,	10,	A2126,	1856.67
SEP13,	1,	A2106,	2490
SEP13,	2,	A2129,	1463.45
SEP13,	10,	A2115,	8719.17
SEP13,	11,	A2115,	3119.92
SEP13,	2,	A2114,	951.2
SEP13,	12,	A2115,	2337.32
SEP13,	29,	A2115,	4405.32

Sorry for the delay, I had to figure out how to even do it first. Here's an example of what 3 months would look like.

data_null__
Jade | Level 19
Maybe you want NEEDLE plot?
JDDowell
Fluorite | Level 6

Thank you, this will work!

Reeza
Super User

Make sure to specify that your axis is a time axis otherwise it may be treating it as numeric and you're missing data so it drops to zero. 

Not 100% sure because no data to test. If you need further help, please post some example data and we can assist you.

 

xaxis type=time valuesformat=monyy5.;

Here are instructions on how to provide sample data as a data step:
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 


@JDDowell wrote:

Hello,

 

I'm trying to plot a series of the number of youth in a program over time. My dates are for a single month, but when I try to plot it my series keeps dropping down to zero for everyday after the 1st of the month, or at least that's what I think happening. 

 

Proc sgplot data=work.efc_pi;
series y='Number Of Youth'n x='Month of Service'n;
run;

 

Series Problem.PNG

 

Currently the date is formatted as Monyy5. is there a different format I need to convert it to in order to solve this problem?


 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 921 views
  • 3 likes
  • 4 in conversation