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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

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

 

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.

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
  • 4 replies
  • 2300 views
  • 1 like
  • 4 in conversation