BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
deengyn
Obsidian | Level 7

Outcome of interest is any complications within 30 days of surgery.

Predictors include patient and disease characteristics, almost all of which are binary. 

 

 

/*Creating dummy variables*/
data ga_1;
set groin;
/*OUTCOME: any complications*/
if comp ^= 'yes' then comp_num = 1;
else if comp = 'yes' then comp_num = 2;
else if comp = . then comp_num = 3;
label comp_num = 'Any complications categorical';

/*PREDICTOR: age*/
age = round((sx_date - birthdate)/365, 2.);
label age = 'Age at surgery';
/*PREDICTOR: sex*/
if sex = 'M' then sex_num = 1;
else if sex = 'F' then sex_num = 2;
label sex_num = 'Sex';
/*PREDICTOR: smoker*/
if smoker = 'no' then smoker_num = 1;
else if smoker = 'yes' then smoker_num = 2;
else if smoker = . then smoker_num = 3;
label smoker_num = 'Smoker categorical';
/*PREDICTOR: cardiac disease*/
if card_dis = 'no' then card_num = 1;
else if card_dis ='yes' then card_num = 2;
else if card_dis = . then card_num = 3;
label card_num = 'Cardiac/vascular categorical';run; 


proc format;
value sex 1 = 'Male' 2 = 'Female';

value smoker 1 = 'N' 2 = 'P' 3 = 'Missing';
value card_dis 1 = 'N' 2 = 'P' 3 = 'Missing';

value comp 1 = 'no' 2 = 'yes' 3 = 'Missing';

run;

I would like to make a non-smoker (SMOKER = NO) as the reference, but it's not working out as I'd hope it to. I'd like to see the OR between non smoker and smoker. 

proc logistic data = ga_2 descending;/
class sex_num (param = ref ref = first)
smoker_num (param = ref ref = first)
 card_num (param = ref ref = first)

model comp_num (event = '1') = age sex_num
smoker_num   card_num

/ clodds = wald orpvalue;
output out = out p = new;
format sex_num sex.
smoker_num smoker.  card_num card_dis.

run;

deengyn_0-1635350953166.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

In SAS, missing is the lowest so is the first technically.

You'll need to set the reference to the No value, using the formatted value.

 

class sex_num ( ref = first)
smoker_num ( ref = 'N')
 card_num (ref = first) / param=ref;

FYI - your code has some syntax errors such as missing semicolons but I'm assuming this is just an example and not your actual code.

 


@deengyn wrote:

Outcome of interest is any complications within 30 days of surgery.

Predictors include patient and disease characteristics, almost all of which are binary. 

 

 

/*Creating dummy variables*/
data ga_1;
set groin;
/*OUTCOME: any complications*/
if comp ^= 'yes' then comp_num = 1;
else if comp = 'yes' then comp_num = 2;
else if comp = . then comp_num = 3;
label comp_num = 'Any complications categorical';

/*PREDICTOR: age*/
age = round((sx_date - birthdate)/365, 2.);
label age = 'Age at surgery';
/*PREDICTOR: sex*/
if sex = 'M' then sex_num = 1;
else if sex = 'F' then sex_num = 2;
label sex_num = 'Sex';
/*PREDICTOR: smoker*/
if smoker = 'no' then smoker_num = 1;
else if smoker = 'yes' then smoker_num = 2;
else if smoker = . then smoker_num = 3;
label smoker_num = 'Smoker categorical';
/*PREDICTOR: cardiac disease*/
if card_dis = 'no' then card_num = 1;
else if card_dis ='yes' then card_num = 2;
else if card_dis = . then card_num = 3;
label card_num = 'Cardiac/vascular categorical';run; 


proc format;
value sex 1 = 'Male' 2 = 'Female';

value smoker 1 = 'N' 2 = 'P' 3 = 'Missing';
value card_dis 1 = 'N' 2 = 'P' 3 = 'Missing';

value comp 1 = 'no' 2 = 'yes' 3 = 'Missing';

run;

I would like to make a non-smoker (SMOKER = NO) as the reference, but it's not working out as I'd hope it to. I'd like to see the OR between non smoker and smoker. 

proc logistic data = ga_2 descending;/
class sex_num (param = ref ref = first)
smoker_num (param = ref ref = first)
 card_num (param = ref ref = first)

model comp_num (event = '1') = age sex_num
smoker_num   card_num

/ clodds = wald orpvalue;
output out = out p = new;
format sex_num sex.
smoker_num smoker.  card_num card_dis.

run;

deengyn_0-1635350953166.png

 

 


 

View solution in original post

2 REPLIES 2
StatDave
SAS Super FREQ
Remove REF=FIRST after SMOKER_NUM in your CLASS statement, or change it to explicitly specify a reference level, such as REF="N". Note that the formatted value is specified, not the internal, numeric value.
Reeza
Super User

In SAS, missing is the lowest so is the first technically.

You'll need to set the reference to the No value, using the formatted value.

 

class sex_num ( ref = first)
smoker_num ( ref = 'N')
 card_num (ref = first) / param=ref;

FYI - your code has some syntax errors such as missing semicolons but I'm assuming this is just an example and not your actual code.

 


@deengyn wrote:

Outcome of interest is any complications within 30 days of surgery.

Predictors include patient and disease characteristics, almost all of which are binary. 

 

 

/*Creating dummy variables*/
data ga_1;
set groin;
/*OUTCOME: any complications*/
if comp ^= 'yes' then comp_num = 1;
else if comp = 'yes' then comp_num = 2;
else if comp = . then comp_num = 3;
label comp_num = 'Any complications categorical';

/*PREDICTOR: age*/
age = round((sx_date - birthdate)/365, 2.);
label age = 'Age at surgery';
/*PREDICTOR: sex*/
if sex = 'M' then sex_num = 1;
else if sex = 'F' then sex_num = 2;
label sex_num = 'Sex';
/*PREDICTOR: smoker*/
if smoker = 'no' then smoker_num = 1;
else if smoker = 'yes' then smoker_num = 2;
else if smoker = . then smoker_num = 3;
label smoker_num = 'Smoker categorical';
/*PREDICTOR: cardiac disease*/
if card_dis = 'no' then card_num = 1;
else if card_dis ='yes' then card_num = 2;
else if card_dis = . then card_num = 3;
label card_num = 'Cardiac/vascular categorical';run; 


proc format;
value sex 1 = 'Male' 2 = 'Female';

value smoker 1 = 'N' 2 = 'P' 3 = 'Missing';
value card_dis 1 = 'N' 2 = 'P' 3 = 'Missing';

value comp 1 = 'no' 2 = 'yes' 3 = 'Missing';

run;

I would like to make a non-smoker (SMOKER = NO) as the reference, but it's not working out as I'd hope it to. I'd like to see the OR between non smoker and smoker. 

proc logistic data = ga_2 descending;/
class sex_num (param = ref ref = first)
smoker_num (param = ref ref = first)
 card_num (param = ref ref = first)

model comp_num (event = '1') = age sex_num
smoker_num   card_num

/ clodds = wald orpvalue;
output out = out p = new;
format sex_num sex.
smoker_num smoker.  card_num card_dis.

run;

deengyn_0-1635350953166.png

 

 


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 359 views
  • 2 likes
  • 3 in conversation