Hi how to get the desired output if we have input like this shown below
Input |
walking_stick, aids_used_for_dressing |
walking_frame, other |
reaching, shopping_and_housework |
rising, walking |
reaching, gripping_and_opening_things, shopping_and_housework |
reaching, gripping_and_opening_things |
raised_toilet_seat, jar_opener_for_jars_previously_opened, bath_rail, long_handled_appliances_in_bathroom |
output like this :
Output |
walking_stick |
aids_used_for_dressing |
walking_frame |
other |
reaching |
shopping_and_housework |
rising |
walking |
reaching |
gripping_and_opening_things |
shopping_and_housework |
reaching |
gripping_and_opening_things |
raised_toilet_seat |
jar_opener_for_jars_previously_opened |
bath_rail |
long_handled_appliances_in_bathroom |
by separating values with comma
Try this
data have;
input string $ 1-200;
infile datalines truncover;
datalines;
walking_stick, aids_used_for_dressing
walking_frame, other
reaching, shopping_and_housework
rising, walking
reaching, gripping_and_opening_things, shopping_and_housework
reaching, gripping_and_opening_things
raised_toilet_seat, jar_opener_for_jars_previously_opened, bath_rail, long_handled_appliances_in_bathroom
;
data want(keep = w);
set have;
do i = 1 to countw(string, ', ');
w = scan(string, i, ', ');
output;
end;
run;
You can follow the code given by @PeterClemmensen
Just another document you can give it a go about your issue ( https://blogs.sas.com/content/iml/2016/07/11/break-sentence-into-words-sas.html#:~:text=The%20COUNTW....)
You will see the solution for a more comprehensive question relating to your issue.
Cheers.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.