03-12-2014 05:59 AM
Here is the table of our query.
|S4.Which of the following conditions have you been diagnosed with by a physician?||TOTAL||MALE||FEMALE|
|BASE :ALL RESPONDENTS||N||298||130||168|
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.
03-14-2014 03:40 AM
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 ;
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_5='Type 1 diabetes'
S4_6='Type 2 Diabetes'
S4_8='High blood pressure'
S4_10='Abnormal LDL, HDL, or triglycerides '
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?';
Kindly ,have a look at the code and let me know .
03-14-2014 05:34 AM
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).
value $sex (multilabel)
'MALE' = 'MALE'
'FEMALE' = 'FEMALE'
'MALE','FEMALE' = 'TOTAL';
proc means data=xxx;
class sex /mlf;
And create a means output table with each by group and male/female/total counts. Then use proc report/print to output this data.