BookmarkSubscribeRSS Feed
DangIT
Fluorite | Level 6

Hi,

I have a data set with that looks like:

ID File_period

1 201301

1 201302

1 201303

2 201302

2 201303

3 201301

I would like a unique data set by ID and a new variable for all the file periods, for example:
ID File_Period_1 File_Period_2 File_Period_3

1 201301 201302 201303

2 201302 201301

3 201301

The number of file periods will vary by ID.

I'm not sure what the best way to run this loop, any help greatly appreciated.

Thanks in advance!

2 REPLIES 2
ballardw
Super User

What you are doing is often called transposing from Long to Wide format.

proc transpose data=have out=want (drop=_name_)

     prefix=File_period_;

by id;

var File_period;

run;

Please make your entries Questions in the format not Discussions when they are questions.

DangIT
Fluorite | Level 6

Thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 795 views
  • 0 likes
  • 2 in conversation