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=.;
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.
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.