BookmarkSubscribeRSS Feed
ritaedeigba0
Calcite | Level 5

I am new to SAS EG 7.1 and i want to recode the zero values and character string specifically this type "?" in columns X1 to X13 in my dataset to NA. I have in total 13 variables and a response variable Y. i have imported the data and its been converted to a SAS data. I have also succeeded in coding the "0" and "1" in the response variable to "No" and "Yes" as i want. please help!. N:B the data is an xlsx file. Thanks

6 REPLIES 6
Reeza
Super User
Why NA? if the ariables are numeric, wouldn't a SAS missing value be more appropriate?
ritaedeigba0
Calcite | Level 5
The original dataset contains 64 variables and i Response variable and
there are so many of the missing values everywhere in the dataset. My
professor said it was better to code them as NA since they were alot.
However, is there an alternative suggestion? I would like to learn it.
Reeza
Super User

NA isn't typically used in SAS so I would review how SAS stores and treats missing and decide if you want missing or some other variable. A lot depends on what you're doing with the data down the line. 

 

 

TomKari
Onyx | Level 15

SAS has "special" missing values; you can use "dot" followed by a letter.

 

So, while both . and .n would be considered missing by computational procedures, you could tell the difference between them in a data step.

 

Tom

ShiroAmada
Lapis Lazuli | Level 10

data test;

  array var(3) $2 x1-x3 ("0" "?" "1"); /* X1='0', X2='?' and x3='1' */

   put X1 X2 X3; 

 do i=1 to dim(var);

    if var(i) in ('0','?') then var(i)='NA'; /*The value for  X1='NA', X2='NA' and x3='1' */

   drop i;

 end;

run;

Reeza
Super User

@ShiroAmada Some of those columns are numeric and some will likely be character. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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