BookmarkSubscribeRSS Feed
ckvv8182
Calcite | Level 5

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.

ckvv8182_1-1648683373456.png

3 REPLIES 3
MichelleHomes
Meteorite | Level 14

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

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
SASKiwi
PROC Star

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;

 

 

Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 861 views
  • 0 likes
  • 4 in conversation