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

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@Kayla_Tan222 

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.

View solution in original post

7 REPLIES 7
Onizuka
Pyrite | Level 9

Hello,

 

First of all : put your code in the "INSERT SAS CODE"

Don't put files on attachment, just say what you want preciselly

Kayla_Tan222
Calcite | Level 5
Hmmm, sorry. I cannot understand what you meant. Can you provide a more detail explanation?

Because i am A very beginner and almost dont know anything.

Kayla_Tan222
Calcite | Level 5

 

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;

 

Patrick
Opal | Level 21

@Kayla_Tan222 

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.

Kayla_Tan222
Calcite | Level 5
Hi, first of all, thanks for your reply!

I have another problem is that what shoud i put after the ‘set’ function, the file location? Or the file name?
Patrick
Opal | Level 21

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.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2135 views
  • 0 likes
  • 3 in conversation