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
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.
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
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;
@ShiroAmada Some of those columns are numeric and some will likely be character.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.