proc tabulate

Reply
Contributor
Posts: 35

proc tabulate

Hi All,

Here is the table of our query.

S4.Which of the following conditions have you been diagnosed with by a physician?TOTALMALEFEMALE
BASE :ALL RESPONDENTSN298130168
Arthritis 19286106
0N
1N1064462
Cancer 279121158
0N
1N19910
Kidney Disease 276119157
0N
1N221111

Could some one explain the syntax of proc tabulate to print values only when the respondents have coded 1 in S4 for the above 3 variables.

thanks

Super User
Super User
Posts: 7,407

Re: proc tabulate

Hi,

Can you not just drop rows with 0 from the input dataset?  If not could you show your code.

Contributor
Posts: 35

Re: proc tabulate

Hi ,

Dropping the rows with 0 from the dataset is not what we r looking for .

Here , is the code for your reference .

PROC TABULATE DATA=PROJECT.U300 ;

WHERE RESPONDENTSTATUS=1;

FORMAT S2 G.;

FORMAT S1 H.;

FORMAT S3 A.;

CLASS  S2 S3;

CLASS  S4_1 S4_2 S4_3 S4_4 S4_5 S4_6 S4_7 S4_8 S4_9 S4_10 S4_11 S4_12 S4_13 S4_14 S4_15;

CLASS S1 ;

TABLE ALL='BASE :ALL RESPONDENTS'*N*F=9.0 S1='',(ALL='TOTAL' S2='')/BOX='S1.Are you, or is any member of your family, currently affiliated with any pharmaceutical company or other healthcare manufacturer,

tTserving as a clinical investigator,consultant, researcher, or in any other capacity?' ;

TABLE ALL='BASE :ALL RESPONDENTS'*N*F=9.0 S2='',(ALL='TOTAL' S2='')/BOX='S2.Are you male or female?' ;

TABLE ALL='BASE :ALL RESPONDENTS'*N*F=9.0 S3='',(ALL='TOTAL' S2='')/BOX='S3.Which of the following represents your age?' ;

TABLE ALL='BASE :ALL RESPONDENTS'*N*F=9.0 S4_1='Arthritis '

   S4_2='Cancer'

   S4_3='Kidney Disease'

   S4_4='Depression'

   S4_5='Type 1 diabetes'

   S4_6='Type 2 Diabetes'

   S4_7='Gestational Diabetes'

   S4_8='High blood pressure'

   S4_9='High cholesterol'

   S4_10='Abnormal LDL, HDL, or triglycerides '

   S4_11='Cardiovascular Disease'

   S4_12='Foot ulcers'

   S4_13='Retinopathy'

   S4_14='Nonalcoholic fatty liver disease'

   S4_15='I have not been diagnosed with any of these conditions'

  ,(ALL='TOTAL' S2='')/BOX='S4.Which of the following conditions have you been diagnosed with by a physician?';

RUN;

Kindly ,have a look at the code and let me know .

Super User
Super User
Posts: 7,407

Re: proc tabulate

TBH Pinky9 I haven't used proc tabulate in over ten years now, pretty much everything is proc report.  I do know that proc tabulate has an out= option, so you could store the output dataset and then post process it to remove those 0 rows, then proc report/print that dataset.  I couldn't see an option from the SAS docs to suppress individual items. 

Another alternative could be to move away from the proc tabulate, and use proc means mlf with proc report (there are many different ways to get these counts, but will go with means mlf here).

Something like:

proc format;
  value $sex (multilabel)
  'MALE' = 'MALE'
  'FEMALE' = 'FEMALE'
  'MALE','FEMALE' = 'TOTAL';
quit;

proc means data=xxx;
  class sex /mlf;
  by ...

And create a means output table with each by group and male/female/total counts.  Then use proc report/print to output this data.

Contributor
Posts: 35

Re: proc tabulate

Thanks , it was helpful

Ask a Question
Discussion stats
  • 4 replies
  • 227 views
  • 0 likes
  • 2 in conversation