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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.