BookmarkSubscribeRSS Feed
Nasya
Obsidian | Level 7

Hi,

 

I am trying to convert numeric to character value for one of the variables, but the missing values are taking the values.

Can some one suggest a way that the missing values are displayed as missing value or correct me what I am missing in the code?

Thanks in advance.

 

Regards,

Nasya

*------------------------------------------------------------------------------*;
* Screener data set
*------------------------------------------------------------------------------*;
data screener (keep=subject age misd dispos);
      set pdata.screener;
       by subject;
run;

/*Sort the data*/
proc sort data= screener;
      by subject;
run;


data screenerfinal;
    set screener;
    attrib TEST length=$200; /*Convert numeric to character and new variable is assigned*/

   if dispos eq 6 then delete;/*Did not qualify*/

   misd_=put(misd, best.);

   if misd le 5 then TEST = ' Normal Level';
   else if misd > 5 then TEST = ' Low Level';
   else if misd eq . then TEST= ' '; 

    keep subject age misd test dispos;

run;


proc sort data= screenerfinal;
    by subject;
run;
1 REPLY 1
Kurt_Bremser
Super User

First you create a dataset with "by subject", which only works if the source is already sorted by subject, so the following sort serves no purpose.

 

Then you create character variable misd_, but never use it, and discard it immediately.

Have you inspected misd for its values?

 

Please post some example data for dataset screener, and tell us what you expect as a result for each observation. Use a data step with datalines to post example data in a usable way.

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