BookmarkSubscribeRSS Feed
peachblozzom
Calcite | Level 5

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.

    

 

2 REPLIES 2
PGStats
Opal | Level 21

Assuming abscode_i are numeric :

if n(of abscode_:) = 0 then call missing (new_variable);

PG

PG
Sudhakar_A
Calcite | Level 5

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

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 709 views
  • 1 like
  • 3 in conversation