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

Hello, I am very new to SAS (just started learning it earlier this semester) and also relatively new to quantitative research (first year PhD student).

 

I am trying to run a regression analysis from a very large secondary dataset that is part of multiple waves (but I am only using one of the waves), that has replaced missing values with various negative numbers (-9 for not in wave, -3 for missing answer, -1 for refuse to answer, etc...). I am trying to create a binary variable from a multiple choice survey variable (because I'm not concerned with the degrees to which the behavior is present, only whether it is present or whether it is not present- so if it's present at al it will be 1, and if it's not present at all it will be 0), but I don't know how to handle the negative numbers so that the analysis just ignores them and doesn't include them for that variable.

 

I apologize if I'm not describing what I'm trying to do properly and if this is something that should be obvious on how to handle it. I appreciate any help figuring out the syntax.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The best approach would be to fix the data.  Get rid of the negative numbers, by changing them to missing values:

 

if var1=-9 then var1=.A;
else if var1=-3 then var1=.B;
else if var1=-1 then var1=.C;

As you can see, there are a variety of ways to code missing values.  You can assign missing values, yet still distinguish the reason why the variable is missing.

 

Regardless of what should happen next, that's going to be the right beginning.  And statistical procedures will recognize those values as missing and (where appropriate) discard the observation.

 

For more information, check the documentation for special missing values:

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=lrcon&docsetTarget=p1xr9f...

 

View solution in original post

2 REPLIES 2
Astounding
PROC Star

The best approach would be to fix the data.  Get rid of the negative numbers, by changing them to missing values:

 

if var1=-9 then var1=.A;
else if var1=-3 then var1=.B;
else if var1=-1 then var1=.C;

As you can see, there are a variety of ways to code missing values.  You can assign missing values, yet still distinguish the reason why the variable is missing.

 

Regardless of what should happen next, that's going to be the right beginning.  And statistical procedures will recognize those values as missing and (where appropriate) discard the observation.

 

For more information, check the documentation for special missing values:

 

https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=lrcon&docsetTarget=p1xr9f...

 

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1876 views
  • 1 like
  • 2 in conversation