BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7
Hi all, I have a long file with ID, time 1, and time 2. There can be multiple of the same ID in the file: Not sure whether it matters, but time1 and time2 are NOT sequential. Or rather, they could be but they are not measuring the same thing over time or anything like that so they could be identical, time1 > time2, or time2>time1. ID time1 time2 1 1 3 1 2 2 1 3 1 2 1 4 2 3 2 3 2 2 What I want is a file that is wide, ie, gives each set of time1 and time2 for a specific ID: ID time1_1 time2_1 time1_2 time2_2 time1_3 time2_3 1 1 3 2 2 3 1 2 1 4 3 2 3 2 2 As you can see, IDs can but don't necessarily have multiple records. The number of time pairings has no upper limit. Any help is much appreciated!
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Please show us (a portion of) the data, as SAS data step code (instructions).

 

Also, could you explain why this wide format is necessary, what can you do better with a wide format compared to a long format.

--
Paige Miller
Rick_SAS
SAS Super FREQ

There are many ways to convert data from a long form to a wide form in SAS.

mkeintz
PROC Star

Please help us help you.

 

  1. Please make clear the arrangement of the data you have to start with, in the form of a working data step, as per the 
    instructions link provided by @PaigeMiller 

  2. Do the same with the desired output layout.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1010 views
  • 0 likes
  • 4 in conversation