🔒 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 11-18-2020 05:32 PM
(1070 views)
Hi all,
Appreciate some help on this .
Thanks in advance.
data a; input word1 $ & 200.; datalines; 101 Capital Region R 000s 101 Capital Region R Uwgt 101 Capital Region R Index 102 Central Coast R Unwgt 102 Central Coast R 000s 102 Central Coast R Vert percent ; run; want 101 Capital Region 101 Capital Region 101 Capital Region 102 Central Coast 102 Central Coast 102 Central Coast
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So what are the rules for doing this truncation of the text? Is it always truncated after the third word, or before the "R", or do you always want the first 18 columns?
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Yes it is before the "R".
Thank you .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One way:
data want; set a; word1 = substr(word1,1,findw(word1,'R')-1); run;
Not the only by any means.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data want;
set a;
where=find(word1,' R ');
word1=substr(word1,1,where-1);
drop where;
run;
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
sorry slight update to requirement , suppose the data is as below , i.e a combination of R and M
data a; input word1 $ & 200.; datalines; 102 Central Coast R 000s 103 Capital Region M 000s ; run;
want ----- 102 Central Coast 103 Capital Region
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Which letter will be added to the separator list with the next update of the requirements?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
where=max(find(word1,' R '),find(word1,' M '));
--
Paige Miller
Paige Miller