DATA Step, Macro, Functions and more

how to create a variable, modify a variable, where it contains lots of missing values,

Accepted Solution Solved
Reply
Super Contributor
Posts: 345
Accepted Solution

how to create a variable, modify a variable, where it contains lots of missing values,

where it contains lots of missing values, say 98% of obs have missing values.

 

whether i use

if var1 NE . then var2 ="M";

or if var1 ne "." then var2 ="M"

it does not work, i do see lots of missing values, but just cannot create var2

any advice?

thanks.


Accepted Solutions
Solution
‎07-13-2016 05:23 PM
Super User
Posts: 11,343

Re: how to create a variable, modify a variable, where it contains lots of missing values,

Missing for character values is not "."

It would be easier to use

 

if not missing(var1) then var2='M';

 

as the Missing function will use the correct comparison for numeric or character as needed.

View solution in original post


All Replies
Solution
‎07-13-2016 05:23 PM
Super User
Posts: 11,343

Re: how to create a variable, modify a variable, where it contains lots of missing values,

Missing for character values is not "."

It would be easier to use

 

if not missing(var1) then var2='M';

 

as the Missing function will use the correct comparison for numeric or character as needed.

Super Contributor
Posts: 345

Re: how to create a variable, modify a variable, where it contains lots of missing values,

thank you, but how to identify those missing values, I need to identy those as well, how to create a variable and give a vlue for those with missing values

Super User
Posts: 11,343

Re: how to create a variable, modify a variable, where it contains lots of missing values,

If missing(var1) then var2='whateveryouwantto assign';

Super User
Posts: 19,822

Re: how to create a variable, modify a variable, where it contains lots of missing values,

Are your variables character or numeric? Are they all the same type?

 

Post an example of what your data looks like and what you want as an output.

I think you want an array, assign the variables to the array and then loop through and create variables that flag if they're missing.

 

Also, what isyour end goal with flagging these as missing? There may be another way to get it. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 246 views
  • 2 likes
  • 3 in conversation