BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

Hello Everybody,

 

having read the SAS Documentation of the MISSING Statement ,I wanted to replace the special charachter "#" (hash) in a numeric variable with the default value "." : 

 

data survey;
   missing '#';
   input id answer;
   datalines;
001 2
002 #
003 1
004 #
005 2
;
run;

However, I do get the following error:

ERROR 36-169: '#' is an invalid special missing value. Only letters A through Z and _ can be used.

In my original data step I am using an infile statement with the missover option , but there I cannot "tell" SAS what sort of missing value, i.e. "#", it has to interpret.

 

Another more complicating fact to it, is the possibilty that the representation of the missing value in the data which has to be read in can be varying, i.e. "#" or "##" or "##(blank)##".

 

The most elegant way which I am looking for, is to tell the infile statement the special characters, that represent a missing value.

Otherwise, I can only see a solution along the lines of using if...then... else if...  constructs or using an select statement.

 

Can anyone help me out?

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

If your answer variable is numerical then below will work and set any source string to missing that can't get converted to a numerical value.

data survey;
  infile datalines truncover dsd dlm=' ';
   input id answer ?? :f16.;
   datalines;
001 2
002 #
003 1
004 #
005 2
;
run;

btw: The term "special missings" means something else in the SAS world. It's how SAS stores missings in a numerical variable. It's not often used and only useful in conjunction with certain procedures.

View solution in original post

1 REPLY 1
Patrick
Opal | Level 21

If your answer variable is numerical then below will work and set any source string to missing that can't get converted to a numerical value.

data survey;
  infile datalines truncover dsd dlm=' ';
   input id answer ?? :f16.;
   datalines;
001 2
002 #
003 1
004 #
005 2
;
run;

btw: The term "special missings" means something else in the SAS world. It's how SAS stores missings in a numerical variable. It's not often used and only useful in conjunction with certain procedures.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 414 views
  • 1 like
  • 2 in conversation