Hello! I've spent a couple of days researching forums and reading papers and I'm stumped. I don't know how to use arrays, macros, or do loops - and i think that's what's needed for this task. This is more complicated than I can do. This is fish habitat data. The ORIGIN is the stream where the fish lives and the DESTINATION is another suitable stream. DISTANCE is the stream length between them, and the LEN and VOL are additional attributes. The data must be sorted by ORIGIN, DISTANCE because I want the transformed columns to be in the order of the closest destination habitats. My dataset as >6000 obs, and some ORIGINs have 25 DESTINATIONS, so there will be about 100 columns in the resulting table. It's what the boss wants - and I'm bummed that I can't figure it out myself. Here's the data: data WORK.CLASS(label='Habitat Data'); infile datalines; input Origin:8. Destination:8. Distance:8. Len:8. Vol:8.; datalines; 1001 999 11891 26.44 193.00 1005 1016 2422 7.03 8.42 1005 944 19437 16.84 74.17 1010 1012 42986 22.10 262.95 1010 988 48093 9.10 26.36 1012 1010 42986 10.66 472.81 1012 988 44204 9.10 26.36 1012 999 47478 26.44 193.00 1016 1005 2422 30.73 62.22 ;;;; Here's the result I want: As I move the data into the columns, I have abbreviated their variable names. I highlighted the DISTANCEs so you can see how they dictate the ordering of the columns. Origin Dest1 Dist1 Len1 Vol1 Dest2 Dist2 Len2 Vol2 Dest3 Dist3 Len3 Vol3 1001 999 11891 26.44 193.00 1005 1016 2422 7.03 8.42 944 19437 16.84 74.17 1010 1012 42986 22.10 262.95 988 48093 9.10 26.36 1012 1010 42986 10.66 472.81 988 44204 9.10 26.36 999 47478 26.44 193.00 1016 1005 2422 30.73 62.22 Thanks a lot! This has been fun, but a dead end. Hope someone out there has fun with it! I'm using SAS 9.4.
... View more