Hi all,
I'm a fairly new SAS programmer and haven't used proc report much yet, but I need to produce a graduation rate table and I believe proc report is my best way to display the result. I'm having trouble getting the compuations to be correct.
I cannot share my data set since it has senstitive information. My code and output are below. What I notice is that it fails to compute once a zero is present.
I would be grateful for any advice or direction you all can provide!
Title "2008 Cohort";
proc report data = gradcombine1;
where cohort = "2008";
column acad_plan n cbm009year, (n cum);
label acad_plan = "Plan"
cbm009year = "Year"
;
define acad_plan / group;
define cbm009year / across;
define n / "#";
define cum / computed "Cumulative %" f=percent8.2;
compute cum;
/* Calculate cumulative percent */
_c4_ = _c3_ / _c2_;
_c6_ = (_c5_ + _c3_) / _c2_;
_c8_ = (_c7_ + _c5_ + _c3_) / _c2_;
_c10_ = (_c9_ + _c7_ + _c5_ + _c3_) / _c2_;
endcomp;
run;
Hi:
Even if you cannot share your data, you can alter it or fake it like this:
data cohort;
infile datalines;
input person $ cohort $ acad_plan $ cbm009year;
datalines;
Person01 2008 AAAA 2009
Person02 2008 AAAA 2009
Person03 2008 AAAA 2009
Person04 2008 AAAA 2009
Person05 2008 AAAA 2009
Person06 2008 AAAA 2009
Person07 2008 AAAA 2009
Person08 2008 AAAA 2009
Person09 2008 AAAA 2009
Person10 2008 AAAA 2010
Person11 2008 AAAA 2010
Person12 2008 AAAA 2010
Person13 2008 AAAA 2010
Person14 2008 AAAA 2013
Person15 2008 AAAA 2014
Person16 2008 BBBB 2009
Person17 2008 BBBB 2010
Person18 2008 BBBB 2010
Person19 2008 CCCC 2010
Person20 2008 CCCC 2010
Person21 2008 CCCC 2010
Person22 2008 CCCC 2010
Person23 2008 CCCC 2010
Person24 2008 CCCC 2010
Person25 2008 CCCC 2010
Person26 2008 CCCC 2010
Person27 2008 CCCC 2010
Person28 2008 CCCC 2010
Person29 2008 CCCC 2010
Person30 2008 CCCC 2010
Person31 2008 CCCC 2010
Person32 2008 DDDD 2009
;
run;
and then your code can be tested easily. Is it everything? No, but is it enough to illustrate your issue, yes.
As you can see, if you switch to the SUM function for the expression to calculate the cumulative percent, then the value gets calculated correctly and then, the missing=0 option shows 0 for the other cells.
cynthia
Hi:
Even if you cannot share your data, you can alter it or fake it like this:
data cohort;
infile datalines;
input person $ cohort $ acad_plan $ cbm009year;
datalines;
Person01 2008 AAAA 2009
Person02 2008 AAAA 2009
Person03 2008 AAAA 2009
Person04 2008 AAAA 2009
Person05 2008 AAAA 2009
Person06 2008 AAAA 2009
Person07 2008 AAAA 2009
Person08 2008 AAAA 2009
Person09 2008 AAAA 2009
Person10 2008 AAAA 2010
Person11 2008 AAAA 2010
Person12 2008 AAAA 2010
Person13 2008 AAAA 2010
Person14 2008 AAAA 2013
Person15 2008 AAAA 2014
Person16 2008 BBBB 2009
Person17 2008 BBBB 2010
Person18 2008 BBBB 2010
Person19 2008 CCCC 2010
Person20 2008 CCCC 2010
Person21 2008 CCCC 2010
Person22 2008 CCCC 2010
Person23 2008 CCCC 2010
Person24 2008 CCCC 2010
Person25 2008 CCCC 2010
Person26 2008 CCCC 2010
Person27 2008 CCCC 2010
Person28 2008 CCCC 2010
Person29 2008 CCCC 2010
Person30 2008 CCCC 2010
Person31 2008 CCCC 2010
Person32 2008 DDDD 2009
;
run;
and then your code can be tested easily. Is it everything? No, but is it enough to illustrate your issue, yes.
As you can see, if you switch to the SUM function for the expression to calculate the cumulative percent, then the value gets calculated correctly and then, the missing=0 option shows 0 for the other cells.
cynthia
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.