G'day!
I'm stuck. I don't know why I'm getting '.' in my output.
When I remove year as the across variable, sas is computing pctvar1 fine (I wanted to check if it was the compute block that was off).
I've the following data and code.
data new;
infile DATALINES dsd missover;
input county $ facility $ total var1 year $;
CARDS;
countya, busybeez, 100, 99, 20012002
countya, childtime, 90, 90, 20012002
countyb, kidzplace, 3, 2 , 20012002
countyb, littlesprouts, 2, 2, 20012002
countya, busybeez, 98, 98, 20022003
countya, childtime, 99, 99, 20022003
countyb, kidzplace, 5, 4 , 20022003
countyb, littlesprouts, 2, 2, 20022003
;
run;
title 'Var1 by county by year';
proc report data=new out=want nowd missing completerows ;
column county
total var1
pctvar1,year;
define county / group
'County';
define year / display across
'Year';
define total / analysis sum noprint ;
define var1 / analysis noprint;
define pctvar1 / computed
'Pct Var1'
format=percent7.1;
compute pctvar1;
pctvar1=var1.sum/total.sum;
endcompute;
run;
When I run it, I'm getting this output:
|
Pct Var1
|
|
Year
|
County
|
20012002
|
20022003
|
countya
|
.
|
.
|
countyb
|
.
|
.
|
My desired output is:
|
Pct Var1
|
|
Year
|
County
|
20012002
|
20022003
|
countya
|
99.4
|
100.0 |
countyb
|
80.0 |
85.7
|
Log:
538
539 data new;
540 infile DATALINES dsd missover;
541 input county $ facility $ total var1 year $;
542 CARDS;
NOTE: The data set WORK.NEW has 8 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
551 ;
552 run;
553
554 title 'Var1 by county by year';
555 proc report data=new out=want nowd missing completerows ;
556 column county
557 total var1
558 pctvar1,year;
559
560 define county / group
561 'County';
562 define year / display across
563 'Year';
564 define total / analysis sum noprint ;
565
566 define var1 / analysis noprint;
567 define pctvar1 / computed
568 'Pct Var1'
569 format=percent7.1;
570 compute pctvar1;
571 pctvar1=var1.sum/total.sum;
572 endcompute;
573
574 run;
NOTE: There were 8 observations read from the data set WORK.NEW.
NOTE: The data set WORK.WANT has 2 observations and 6 variables.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.10 seconds
cpu time 0.01 seconds