BookmarkSubscribeRSS Feed
SPChoudary
Fluorite | Level 6

Here is another example which will work in all scenarios.

 

data inds;
 invar = "There was once a merchant who employed many carpenters and masons to build a temple in his garden. Regularly, they would start work in the morning; The Monkey And The Wedge - Panchatantra Story Pictureand take a break for the mid-day meals, and return to resume work till evening. One day, a group of monkey arrived at the site of the building and watched the workers leaving for their mid-day meals. One of the carpenters was sawing a huge log of wood. Since, it was only half-done; he placed a wedge in between to prevent the log from closing up. He then went off along with the other workers for his meal.";
 output;
 invar = "Small string";
 output;
 invar = " ";
 output;
run;

 

data outds_row;
 set inds;
 obs_seq = _n_;
 length outvar $200;
 sub_invar = invar;
 itrno = 0;
 do until (sub_invar = " ");
  dlmpos = 199 - lengthn(scan(reverse(substrn(sub_invar, 1, 200)), 1, " "));
  outvar = strip(substrn(sub_invar, 1, dlmpos));
  sub_invar = strip(substrn(sub_invar, dlmpos + 1));
  itrno + 1;
  output;
 end;
 drop sub_invar dlmpos;
run;

 

proc sort data = outds_row;
 by obs_seq itrno;
run;

 

proc transpose data = outds_row out = outds_col prefix = outvar;
 by obs_seq;
 id itrno;
 var outvar;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 10747 views
  • 3 likes
  • 11 in conversation