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

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!

 

2008 cohort.PNG

 

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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.

 

change_to_sum_function.png

 

  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

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
Are you getting any error messages in the log? Is it possible for you to make some "fake" data or use one of the SASHELP datasets to illustrate your example???

Are you numbers actually 0 in those cells or are they missing. When you use missing values in arithmetic, the result is always missing, so
. / 0 or ./13 would not work correctly and if you have the option of missing=0, then you would be seeing 0 in the cells.

cynthia
Cynthia_sas
SAS Super FREQ

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.

 

change_to_sum_function.png

 

  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

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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