Help using Base SAS procedures

Need a pivot kind of output on a sas dataset

Reply
Frequent Contributor
Posts: 76

Need a pivot kind of output on a sas dataset

D/All,
I have a below sample dataset -
field1,field2,status
AM1,BM1,ST1
AM1,BM1,ST3
AM1,BM1,ST2
AM1,BM1,ST4
AM1,BM1,ST4
AM1,BM1,ST1
AM1,BM1,ST2
AM1,BM1,ST3
AM1,BM1,ST1
AM1,BM1,ST3
AM1,BM1,ST1
AM1,BM1,ST1
AM1,BM1,ST1
AM1,BM1,ST1
AM1,BM1,ST1
AM1,BM1,ST1
AM1,BM1,ST3
AM1,BM2,ST1
AM1,BM2,ST3
AM1,BM2,ST3
AM1,BM2,ST4
AM1,BM2,ST3
AM1,BM2,ST1
AM1,BM2,ST2
AM1,BM2,ST3
AM1,BM2,ST1
AM1,BM2,ST2
AM1,BM2,ST3
AM1,BM2,ST1
AM1,BM2,ST3
AM1,BM2,ST2
AM1,BM2,ST2
AM1,BM2,ST1
AM1,BM2,ST2
Need to create similar freq dataset.
field1,field2,ST1,ST2,ST3,ST4
AM1,BM1,9,2,4,2
AM1,BM2,5,5,6,1
I cannot attach any excel data hence the input and output both are in CSV format. Request if anyone can provide me a way to create this format output.
For now ST1, ST2, ST3, ST4 are fixed observations but need a code which dynamically creates the output variables.
Thanks a lot,
Rgds, Anil
.
Super User
Posts: 19,813

Re: Need a pivot kind of output on a sas dataset

1. Run a proc freq to get the counts

2. Use Proc Transpose to transpose to required format

Ask a Question
Discussion stats
  • 1 reply
  • 158 views
  • 0 likes
  • 2 in conversation