Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flatten data file 1

Status
Not open for further replies.

jackieflash

Vendor
Sep 21, 2002
8
US
IDNUM Type Plan Desc StMonth EndMonth
9578 1 AA1 Single Jan-00 Jan-00
9578 1 AA2 Double Jan-00 Jan-00
9578 1 AA3 Triple Jun-00 Jul-00
9578 1 AA4 Quarter Jul-00 Jul-00
9578 2 AA5 Fourth Jan-00 Jan-00
9578 2 AA5 Fourth Dec-00 Dec-00
2222 1 AA7 Fifth Feb-00 Feb-00
2222 1 AA7 Fifth Apr-00 May-00
2222 1 AA9 Double Jan-00 Jan-00
2222 1 AA10 Single Feb-00 Feb-00


Dear SAS Experts,
I would like to flatten a file by IDNUM, Type and StMonth. I would need
arrays created for Plan, Desc,
StMonth and EndMonth. A person can have either Type=1or 2 or both.
StMonth and EndMonth are date variables.

For e.g.. For the above data I would like all the data for the same
IDNUM, StMonth and Type on the same line.
All the Jan00 data for IDNUM 9578 and Type 1 would be on one line.


All the Jun00 data for IDNUM 9578 and Type 1 would be on another line
and so on and so forth....
All the Jan00 data for IDNUM 9578 and Type 2 would be on another line.


Maximum # of entries for the same IDNUM Type and StMonth is 11.
Thus maximum # of variables for each array would be 11.
So for Start Month we will have 11 different variables - SM1 to
SM11,
Similarly for EndMonth, Plan, Desc.


Basically I need one entry for each IDNUM Type STMonth
combination.


Hope this is clear. Let me know if you have any questions.
Much obliged for any assistance.
Thanks,
Tyro


 
Look up Proc Transpose in the documentation. That'll do the job for you without using arrays. It's a little complex to use, but there will be examples. Once you get the hang of Transpose, you'll never look back. I unfortunately don't use it enough so I always have to refer back to the manual. If you have any problems understanding it, post back and I'll see what I can do.
 
Thanks Chris, I will look further into Proc Transpose.
Hopefully that will solve my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top