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.

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
  • 1 reply
  • 730 views
  • 0 likes
  • 2 in conversation