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

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

4 REPLIES 4
Shmuel
Garnet | Level 18

Just run:

 

PROC TABULATE  data=com   /* missing  */;
CLASS  pop sot ;
TABLE (pop all='Totale'),
     sot * (rowpctn) ;
RUN;
Elena
Obsidian | Level 7

Run but not well.

The table whithout missing in this

 

Cattura2.JPG

 

Astounding
PROC Star

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;

 

 

ballardw
Super User

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.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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