🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-21-2019 01:26 PM
(1241 views)
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
| date | state | st_nm_des |
| 15JAN2018 | AL | ALABAMA |
| 16JAN2018 | MD | |
| 16JAN2018 | DE | |
| 17JAN2018 | CT | Connecticut |
| 18JAN2018 | FL | Florida |
| 19JAN2018 | ID | Idaho |
| 20JAN2018 | ME | Maine |
Can anyone please help
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for help
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thank you so much for helping me