Hi,
I have this dataset and I'd like to do a proc tabulate to produce a tabulate like the one below but without the column missign.
data com;
infile datalines;
input pop sot
;
datalines;
1 1
2 .
3 1
1 .
2 1
3 .
1 .
2 1
3 1
1 .
2 .
3 1
;
run;
PROC TABULATE data=com missing;
CLASS pop sot ;
TABLE (pop all='Totale'),
sot * (rowpctn) ;
RUN;
thanks!
When you want the % of a flag, you are better off using 0 instead of missing in your data:
data com;
infile datalines;
input pop sot;
if sot=. then sot=0;
datalines;
..........
;
Then you have choices, but the basic idea is to compute the MEAN of the variable. You can label it as the Row % if you want, but calculate the mean.
proc tabulate data=com;
class pop;
var sot;
tables (pop all='Totale'), sot*mean='Row %';
run;
This will get you a decimal fraction, such as 0.25. It you really want to convert this, you could apply a format:
sot*mean='Row %' * f=percent9.2;
Just run:
PROC TABULATE data=com /* missing */;
CLASS pop sot ;
TABLE (pop all='Totale'),
sot * (rowpctn) ;
RUN;
Run but not well.
The table whithout missing in this
When you want the % of a flag, you are better off using 0 instead of missing in your data:
data com;
infile datalines;
input pop sot;
if sot=. then sot=0;
datalines;
..........
;
Then you have choices, but the basic idea is to compute the MEAN of the variable. You can label it as the Row % if you want, but calculate the mean.
proc tabulate data=com;
class pop;
var sot;
tables (pop all='Totale'), sot*mean='Row %';
run;
This will get you a decimal fraction, such as 0.25. It you really want to convert this, you could apply a format:
sot*mean='Row %' * f=percent9.2;
Try
PROC TABULATE data=com ; CLASS pop; class sot /missing ; TABLE (pop all='Totale'), sot * (rowpctn) ; RUN;
Though I preferr to use 0/1 coded variables as Var variables as N, Sum and Mean become very useful as a group: N= total valid responses (either 0 or 1), Sum= number of 1 valued responses and Mean with a percent format is the percentage of 1 responses.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.