BookmarkSubscribeRSS Feed
iressa131
Calcite | Level 5

Hello:)

 

So i have the two variables AGE (41-65) and SMOKE. I am trying to see if there is an association between smoking and patients aged 65 and over vs. all others. Theres only one patient aged 65 and none over. Do i have to first create a new variable and then do the chi square test?

 

This is what I'm thinking let me know if I should be doing something else please thanks!

DATA work.HW2 ;
set  work.HW2;
INPUT person sap AGE SMK group gender wt ht chol ; 
if AGE = 65 then AGESMK = 65over ;
if AGE < 65 then AGESMK = others;
run;

DATA work.HW2;
proc freq;
title8 'Part H: Smoking and 65 and Over vs. All Others Association ';
WEIGHT AGESMK;
TABLES 65over* others/CHISQ;
RUN;
3 REPLIES 3
iressa131
Calcite | Level 5

HelloSmiley Happy

 

So i have the two variables AGE (41-65) and SMOKE. I am trying to see if there is an association between smoking and patients aged 65 and over vs. all others. Theres only one patient aged 65 and none over. Do i have to first create a new variable and then do the chi square test?

 

This is what I'm thinking let me know if I should be doing something else please thanks!

DATA work.HW2 ;
set  work.HW2;
INPUT person sap AGE SMK group gender wt ht chol ; 
if AGE = 65 then AGESMK = 65over ;
if AGE < 65 then AGESMK = others;
run;

DATA work.HW2;
proc freq;
title8 'Part H: Smoking and 65 and Over vs. All Others Association ';
WEIGHT AGESMK;
TABLES 65over* others/CHISQ;
RUN;
ballardw
Super User

You will get a warning that 25 percent of your cells had a count of less than 5 and that Chi-square may not be the appropriate test.

 

Without data more data in your 'over 65' group I don't think you'll find much luck. You might see if another age group such as 60+ tells you anything.

 

Or if the requirement is 65 and older report insufficient data in that age group. Then go back to the sample or study design and find out why...

 

You data step looks odd at worst and possibly unworkable. You have an Input statement which does not have a value for 65over (which is an invalid variable name) or  others. So you would get errors and missing values assigned to AGESMK.

 

I would expect that you either create a generic age group variable such as

 

agegroup = (age ge 65);

 

And use freq similar to:

proc freq;
title8 'Part H: Smoking and 65 and Over vs. All Others Association ';
TABLES agegroup*smk/CHISQ;
RUN;

With this case you really need to provide actual data as what you have posted is kind of hard to determine actual behavior of your data.

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 1961 views
  • 2 likes
  • 3 in conversation