- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
below is code to get ParkType, as Monument or Park.
data np_summary2; set pg1.np_summary; ParkType=scan(parkname,-1); keep Reg Type ParkName ParkType; run;
I would be interested to see ParkType, as National Monument or National Park.
How to do it using SCAN or other function?
I can created separate two column and then concatenate, but would want simple or short way to do the same.
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, take a look at the data in pg1.np_summary:
Assuming that the word "National" is next to the last piece of ParkName, which it is in these records, then this code would do what you're asking:
data np_summary_alt;
set pg1.np_summary;
ParkType=catx(' ',scan(parkname,-2),scan(parkname,-1));
keep Reg Type ParkName ParkType;
run;
proc print data=np_summary_alt(obs=10);
run;
You can scan and concatenate without creating 2 new variables.
Hope this helps,
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, take a look at the data in pg1.np_summary:
Assuming that the word "National" is next to the last piece of ParkName, which it is in these records, then this code would do what you're asking:
data np_summary_alt;
set pg1.np_summary;
ParkType=catx(' ',scan(parkname,-2),scan(parkname,-1));
keep Reg Type ParkName ParkType;
run;
proc print data=np_summary_alt(obs=10);
run;
You can scan and concatenate without creating 2 new variables.
Hope this helps,
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content