Date: Fri, 19 Apr 2002 12:59:35 -0400 mimi "SAS(r) Discussion" mimi JHU sas data manipulate... text/plain; charset=us-ascii

hi guys,

anyone got an idea how to do this problem (attached at the end)? it

beats me (and some other people that i know ).

sincerely yours, joe chen

--------------------

suppose we have a data like the following:

DATE TS TIME MM BI BS 9/4/2001 X 1 A 8.6 7 9/4/2001 X 1 B 7.5 1 9/4/2001 X 2 B 8.5 3 9/4/2001 X 3 B 8.7 9 9/4/2001 X 4 C 8.7 10 9/4/2001 X 5 A 8.65 10 9/4/2001 Y 1 L 60.2 3 9/4/2001 Y 1 K 60.22 1 9/4/2001 Y 2 K 60.2 7 9/4/2001 Y 2 M 59 10 ...... (other data lines)

note that we have no clue about the contents of TS, TIME, MM, BI, and BS before SAS reads the data.

How would you do to transform it into the following: DATE TS TIME MM1 BI1 BS1 MM2 BD2 BS2 MM3 BI3 BS3 9/4/2001 X 1 A 8.6 7 B 7.5 1 . . . 9/4/2001 X 2 A 8.6 7 B 8.5 3 . . . 9/4/2001 X 3 A 8.6 7 B 8.7 9 . . . 9/4/2001 X 4 A 8.6 7 B 8.5 3 C 8.7 10 9/4/2001 X 5 A 8.65 10 B 8.5 3 C 8.7 10 9/4/2001 Y 1 K 60.22 1 L 60.2 3 . . . 9/4/2001 Y 2 K 60.2 7 L 60.2 3 M 59 10 ......

in other words, how to reshape the data structure from long to wide by TS and TIME; however, keep on updating (BI,BS) when new information arrives. a couple of things may cause some trouble: 1. new MM comes into play at later times (for example, in our date, MM=C comes in at TIME=4; MM=M comes in at TIME=2). let's say if the next obs is: 9/4/2001 Y 2 N 60 1 then we are expecting the see the resulting data as the following: DATE TS TIME MM1 BI1 BS1 MM2 BD2 BS2 MM3 BI3 BS3 MM4 BI4 BS4 9/4/2001 X 1 A 8.6 7 B 7.5 1 . . . . . . 9/4/2001 X 2 A 8.6 7 B 8.5 3 . . . . . . 9/4/2001 X 3 A 8.6 7 B 8.7 9 . . . . . . 9/4/2001 X 4 A 8.6 7 B 8.5 3 C 8.7 10 . . . 9/4/2001 X 5 A 8.65 10 B 8.5 3 C 8.7 10 . . . 9/4/2001 Y 1 K 60.22 1 L 60.2 3 . . . . . . 9/4/2001 Y 2 K 60.2 7 L 60.2 3 M 59 10 N 60 1 ...... 2. the MMs for each TS changes (for example, in our data, for TS=X, the MMs are: A,B,C; for TS=Y, the MMs are: K,L,M,N), as well as the TIME.

Back to: Top of message | Previous page | Main SAS-L page