BookmarkSubscribeRSS Feed
Corinthian94
Obsidian | Level 7

Hi all,

 

I'm trying to do an interaction assessment for a dataset I have using dummy variables coded as different smoking statuses and a lifestyle score I have been using. However, when I try to multiply these together to create a variable to use in the analysis, no values are created. Both variables are numerical with the score ranging from 5-25 and the dummy variables being coded as 0/1. Code posted below: 

 

ecl_nonsmoke = ecl2_score*dummy_nosmoke;
ecl_cursmoke = ecl2_score*dummy_cursmoke;
ecl_forsmoke = ecl2_score*dummy_forsmoke;

 

The proc freq I run afterwards shows that all values for the newly created variables are missing, even though all the observations in the dataset have values for the score and the dummy variables used in the calculation. Any ideas why this could be happening? Thanks!

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Since we can't look in your data set, we can't tell why you are getting missing values. However, you can look at the data set, and so you should look in the data set, it will likely be obvious. Also, you should look to see if there is a warning in the log about missing values being created.

 

In addition, if you are working with PROC GLM, you do not need to (and should not) create your own dummy variables. PROC GLM creates the dummy variables for you behind the scenes, so you don't have to go through the effort of creating the dummy variables yourself (and possibly getting it wrong).

--
Paige Miller
ballardw
Super User

@Corinthian94 wrote:

Hi all,

 

I'm trying to do an interaction assessment for a dataset I have using dummy variables coded as different smoking statuses and a lifestyle score I have been using. However, when I try to multiply these together to create a variable to use in the analysis, no values are created. Both variables are numerical with the score ranging from 5-25 and the dummy variables being coded as 0/1. Code posted below: 

 

ecl_nonsmoke = ecl2_score*dummy_nosmoke;
ecl_cursmoke = ecl2_score*dummy_cursmoke;
ecl_forsmoke = ecl2_score*dummy_forsmoke;

 

The proc freq I run afterwards shows that all values for the newly created variables are missing, even though all the observations in the dataset have values for the score and the dummy variables used in the calculation. Any ideas why this could be happening? Thanks!


Show the log from running the code. Include the code for the entire data set and all notes.

 

Some Possible causes in no particular likelihood order: misspelling one or more variable names which would 1) create a variable with missing values and 2) use missing values in the calculation; using a variable before you define it; looking at the wrong data set; other assignment statements for the same variables; conditional assignment statements where the condition is never true (or always true) so the assignment never executes.

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 427 views
  • 1 like
  • 3 in conversation