DATA DM1;
SET CHETNA.DM;
ETHNIC_DEC= UPCASE(ETHNIC);
PUT ETHNIC=;
RUN;
above code i tried it does not work.
below is original data and requirement is Read all ETHNIC_DEC in upper case and save it in new var ETHNIC.
Hi @ckvv8182,
It seems you have mixed up your input variable in the UPCASE function. Try the following...
DATA DM1;
SET CHETNA.DM;
ETHNIC= UPCASE(ETHNIC_DEC);
PUT ETHNIC=;
RUN;
Note the PUT statement just puts the values into the log. You don't need to include it to create the variable. The statement above does this.
Kind Regards,
Michelle
Looks like you have your assignment statement the wrong way around - the variable you are saving to should be to the left the the equals sign. Try this.
DATA DM1;
SET CHETNA.DM;
ETHNIC = UPCASE(ETHNIC_DEC);
PUT ETHNIC=;
RUN;
From what the picture(*) tells me, the dataset already contains a numeric variable ETHNIC. You need to get ruid of it before you can create a new character variable with the same name. Use a DROP= dataset option in your SET statement for this.
*) Never use pictures to provide data. Use a data step with datalines, posted in a code box, so we can easily recreate your dataset for testing, without having to guess variable attributes and raw content.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.