Help using Base SAS procedures

Proc tabulate. No print missing

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

Proc tabulate. No print missing

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!

 

 

Cattura.JPG

 


Accepted Solutions
Solution
‎09-28-2017 02:11 AM
Super User
Posts: 6,751

Re: Proc tabulate. No print missing

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;

 

 

View solution in original post


All Replies
Trusted Advisor
Posts: 1,837

Re: Proc tabulate. No print missing

Just run:

 

PROC TABULATE  data=com   /* missing  */;
CLASS  pop sot ;
TABLE (pop all='Totale'),
     sot * (rowpctn) ;
RUN;
Occasional Contributor
Posts: 18

Re: Proc tabulate. No print missing

Run but not well.

The table whithout missing in this

 

Cattura2.JPG

 

Solution
‎09-28-2017 02:11 AM
Super User
Posts: 6,751

Re: Proc tabulate. No print missing

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;

 

 

Super User
Posts: 13,498

Re: Proc tabulate. No print missing

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.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 477 views
  • 1 like
  • 4 in conversation