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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1317 views
  • 1 like
  • 3 in conversation