02-26-2016 03:59 PM
Hello ..Hope this is an easy question.. trying to create a data step that transposes data into columns as such.
I have a file that I loaded that has groups of data with spacing.. like this: This is how it looks.. I need have in column 1 -->Group 1, then recognize the word end and the second column is Group2 and all the name under group 2.. need to repeat this over and over.
02-26-2016 04:17 PM
In my list there is one column.. I Need to transpose to many columns like this
Group 1 Group 2
I need a loop to recognize the word "end" and name the column to the right with the variable below end.. which is Group2.. and everything under Group 2 is in that column .. until the next word "end" shows up
Does that make sense?
02-26-2016 04:26 PM
Is it a text file or a SAS data set?
Post a sample that reflects exactly what your data looks like, and one that is what you're trying to get.
02-26-2016 06:10 PM
02-26-2016 10:33 PM
02-26-2016 11:26 PM
This should do it:
data grp; length name $20; infile datalines truncover; input name&; datalines4; Group 1 Paul Jason Kevin end; Group 2 Charlie steve damien end; ;;;; data grp2; set grp; where name is not missing; if name =: "end" then do; col + 1; line = 0; end; else do; line + 1; output; end; run; proc sort data=grp2; by line col; run; proc transpose data=grp2 out=grp3(drop=line _name_) prefix=col_; by line; id col; var name; run;
02-27-2016 01:51 AM