Hi all,
would like to ask what code should I use in order to replace the specific missing variables column (not all, as I have total 7 missing variable columns) with
differences between multiple variables columns. was struggling this for few hours and unable to get solutions even after I tried to google search.
I had attached two screenshots with this post.
Hope to get some replies asap.Thanks.
here's my code below
data P201812;
%let _EFIERR_=0;
infile '\\D:\POLA\201812.csv' dlm=',' MISSOVER DSD lrecl=32767 $3.;
firstobs=2;
informat dev10yr_fy 4.0;
format dev10yr_fy 4.0;
INPUT
dev10yr_fy;
if _ERROR_ then call symputx('_EFIERR_',1);
run;
You write: "what code should I use in order to replace the specific missing variables column".
Given your latest post I assume you've got a problem when doing calculations with variables where one of them is missing.
You can use the SUM() function for such situations as this function treats missing values differently (excluding them from the calculation).
data zclmosnet;
set your_given_input;
zclmosnet = sum(zclmos,-zosqs,-zosvc,-zosaf,-zossp01);
keep zclmosnet;
run;
As for posting code: Use the running man icon as I've done above. This lets you post code that doesn't get messed up.
Hello,
First of all : put your code in the "INSERT SAS CODE"
Don't put files on attachment, just say what you want preciselly
Hi, is it the below code is what you meant?
But for the your_given_input , what should i put actually? the data file?
data zclmosnet;
set your_given_input;
zclmosnet = zclmos - zosqs-zosvc-zosaf-zossp01;
keep zclmosnet ;
run;
You write: "what code should I use in order to replace the specific missing variables column".
Given your latest post I assume you've got a problem when doing calculations with variables where one of them is missing.
You can use the SUM() function for such situations as this function treats missing values differently (excluding them from the calculation).
data zclmosnet;
set your_given_input;
zclmosnet = sum(zclmos,-zosqs,-zosvc,-zosaf,-zossp01);
keep zclmosnet;
run;
As for posting code: Use the running man icon as I've done above. This lets you post code that doesn't get messed up.
If you read data from an external file like in your original code sample then it's the INPUT statement which maps your source data into SAS variables. So any operations you want to perform on SAS variables must come after the INPUT statement.
If you read data from a source table via a SET statement then any operations you want to perform with the values coming from a source table must come after the SET statement.
Thanks Patrick! You help me a lot!
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.