BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jl1005
Obsidian | Level 7

Hi everyone,

 

So I ran a SQL query to return how many times a specific event occurred. Here's a snippet of what that table looks like:

sample transpose.JPG

 

I'd like to merge this table with another table, but this one needs transposed first.

 

I'd like to keep the year_id and bat_id as they are, but have the year_id's collapsed into one year. So combine the multiple 1999's in to one single row for 1999, for that batter. Then have the event_cd's be the new column headers and the counts fill each row, if that makes sense. The words columns are just labels for the event_cd's; it'd be nice to have those as column headings, but not neccessary. 

 

So here's what the final table structure would look like, if possible.

 

desired transpose.JPG

 

I really appreciate the help,

 

Justin

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The data in your two photographs don't seem to agree with each other.

You should be able to use the ID statement in PROC TRANSPOSE.

 

proc transpose data=have out=want prefix=event_ ;
  by year_id bat_id ;
  id event_cd ;
  var count;
run;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

The data in your two photographs don't seem to agree with each other.

You should be able to use the ID statement in PROC TRANSPOSE.

 

proc transpose data=have out=want prefix=event_ ;
  by year_id bat_id ;
  id event_cd ;
  var count;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 846 views
  • 0 likes
  • 2 in conversation