Hello,
I have 150 Obs with mutiple statment from 24 months, so its a long list, and I am trying to make it Long to wide.
here I have my code, can you please have a look, so see how would I add a Do-Loop on this to make my life easier? Thank you.
data Test;
set From;
by ID;
retain Statement1-Statement24;
array misser Statement1-Statement24;
if first.ID=1 then do over misser;
misser =.;
end;
if Count=1 then do;
Statement_01=Statement;
end;
if CountForSTMT=2 then do;
Statement_02=Statement;
end;
.
.
.
if CountForSTMT=24 then do;
Statement_24=Statement;
end;
if last.ID=1 then output;
run;
Is this what you're trying to do:
http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm
If so, consider using a direct PROC TRANSPOSE instead, see the examples here:
First clarify if you want Statement_02 as used in your assignment or Statement2 as used in your Retain and Array statements.
You don't help yourself by having two different indexing variables count and CountForStmt.
No need for any do loop since your CountForStmt is the index into the array that you need:
if CountForStmt> 1 then misser[CountForStmt]=statement;
replace all of the 2 through 24 code that you indicate.
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!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.