BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jhh197
Pyrite | Level 9

I have a SAS dataset TEST and i wanted to update st_nm_des column where the description is missing on a specific date 16JAN2018.
MD- Maryland and DE - Delaware

 

datestatest_nm_des
15JAN2018ALALABAMA
16JAN2018MD 
16JAN2018DE 
17JAN2018CTConnecticut
18JAN2018FLFlorida
19JAN2018IDIdaho
20JAN2018MEMaine

 

Can anyone please help

1 ACCEPTED SOLUTION

Accepted Solutions
Krueger
Pyrite | Level 9
data have;
input date :date9. state $ st_nm_des :$11.;
format date date9.;
cards;
15JAN2018 AL ALABAMA
16JAN2018 MD .
16JAN2018 DE .
17JAN2018 CT Connecticut
18JAN2018 FL Florida
19JAN2018 ID Idaho
20JAN2018 ME Maine
run;

data want;
set have;
if date = '16JAN2018'd and state = 'MD' then st_nm_des = 'Maryland';
if date = '16JAN2018'd and state = 'DE' then st_nm_des = 'Delaware';
run;

View solution in original post

4 REPLIES 4
FreelanceReinh
Jade | Level 19

Hello @jhh197,

 

Have you tried the STNAME or STNAMEL function?

 

Example:

data test;
input date :date9. state $ st_nm_des :$20.;
format date date9.;
cards;
15JAN2018 AL ALABAMA
16JAN2018 MD .
16JAN2018 DE .
17JAN2018 CT Connecticut
18JAN2018 FL Florida
19JAN2018 ID Idaho
20JAN2018 ME Maine
;

data test;
modify test;
where st_nm_des=' ';
st_nm_des=stnamel(state);
replace;
run;
Krueger
Pyrite | Level 9
data have;
input date :date9. state $ st_nm_des :$11.;
format date date9.;
cards;
15JAN2018 AL ALABAMA
16JAN2018 MD .
16JAN2018 DE .
17JAN2018 CT Connecticut
18JAN2018 FL Florida
19JAN2018 ID Idaho
20JAN2018 ME Maine
run;

data want;
set have;
if date = '16JAN2018'd and state = 'MD' then st_nm_des = 'Maryland';
if date = '16JAN2018'd and state = 'DE' then st_nm_des = 'Delaware';
run;
jhh197
Pyrite | Level 9
Thank you so much for help
jhh197
Pyrite | Level 9
thank you so much for helping me

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