SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abhinayingole
Obsidian | Level 7

I have 5 character variable, all start with prefix '_' (variable name).

I need to set missing values for all these variable and don't want to write array for this.

could someone please help?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

This will set ALL variables whose names start with _ to missing:

data want;
  set have;
  call missing (of _:);
run;

The : is a list creator for all the variable that start with a common string (could be more characters in common). The "of" tells the function that you want to use a list.

Call missing is one of the few functions that operates on mixed numeric or character variables so is good go to choice for setting things missing. Arrays would require two different arrays if you have mixed variable types.

 


@abhinayingole wrote:

I have 5 character variable, all start with prefix '_' (variable name).

I need to set missing values for all these variable and don't want to write array for this.

could someone please help?


If you have other variable that start with _ that you don't want to set to missing then just list them in the Call Missing function:

Call missing(_x, _y, _pdq); or what have you.

View solution in original post

2 REPLIES 2
ballardw
Super User

This will set ALL variables whose names start with _ to missing:

data want;
  set have;
  call missing (of _:);
run;

The : is a list creator for all the variable that start with a common string (could be more characters in common). The "of" tells the function that you want to use a list.

Call missing is one of the few functions that operates on mixed numeric or character variables so is good go to choice for setting things missing. Arrays would require two different arrays if you have mixed variable types.

 


@abhinayingole wrote:

I have 5 character variable, all start with prefix '_' (variable name).

I need to set missing values for all these variable and don't want to write array for this.

could someone please help?


If you have other variable that start with _ that you don't want to set to missing then just list them in the Call Missing function:

Call missing(_x, _y, _pdq); or what have you.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2673 views
  • 2 likes
  • 2 in conversation