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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1386 views
  • 2 likes
  • 2 in conversation