I have character variables, abscode_1, abscode_2, ..., abscode_8. I'm going to use "if & else" statement in SAS to create a new variable by selecting all the variables.
Here's my question.
I am going to assign a new variable as missing if all the variables are missing. But I don't know how to code this.
I would appreciate your help.
Assuming abscode_i are numeric :
if n(of abscode_:) = 0 then call missing (new_variable);
PG
Additional information to PGSTATS reply.
n() ==> will count the no of non-missing values in all the variable listed
Call missing will assign missing values to numeric or character variable which is listed in () so we need to decide the new variable typebefore using it in the function. or you can give it as New_variable=.;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.