BookmarkSubscribeRSS Feed
lisa2002
Fluorite | Level 6

Hello, 

 

I need some assistance with creating a frequency table of smoking status by cholesterol status suppress the Row Pct and Col Pct 

 

This is what I have to create a frequency table for smoking status however 

 

proc freq data=sashelp.heart;
tables Smoking_Status/Chol_Status;
quit;

 

I tried to use example 

proc freq data=SummerSchool order=data;
   tables Internship*Enrollment / chisq;
   weight Count;
run;  

 However I'm not getting smoking status by cholesterol status 

 

Status     Smoking_Status       Chol_Status

dead        Heavy (16-25)            desirable                   

alive        non-smoker                 desirable

dead        moderate (16-25)       high

alive         non-smoker                borderline

alive         light (1-5)                   borderline                                  

3 REPLIES 3
PaigeMiller
Diamond | Level 26
tables Internship*Enrollment / chisq nocol norow;

Please go back to your first post in this thread and provide a more meaningful title.

--
Paige Miller
Reeza
Super User

@lisa2002 wrote:

Hello, 

 

I need some assistance with creating a frequency table of smoking status by cholesterol status suppress the Row Pct and Col Pct 

 

This is what I have to create a frequency table for smoking status however 

 

proc freq data=sashelp.heart;
tables Smoking_Status/Chol_Status;
quit;

 

I tried to use example 

proc freq data=SummerSchool order=data;
   tables Internship*Enrollment / chisq;
   weight Count;
run;  

 However I'm not getting smoking status by cholesterol status 

 

Status     Smoking_Status       Chol_Status

dead        Heavy (16-25)            desirable                   

alive        non-smoker                 desirable

dead        moderate (16-25)       high

alive         non-smoker                borderline

alive         light (1-5)                   borderline                                  


Smoking_Status is not included in your PROC FREQ so it won't be included in the results. It depends on how you want it, but you could just add smoking_status to the table statement or put it as a BY statement to have it done for each status.

ballardw
Super User

Your code:

proc freq data=sashelp.heart;
tables Smoking_Status/Chol_Status;
quit;

generates errors because the / is used to indicate options such as the types of tests or output are required.

 

The * between variable names is used to request a cross-tabulation

 

proc freq data=sashelp.heart;
tables Smoking_Status*Chol_Status;
quit;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 524 views
  • 0 likes
  • 4 in conversation