BookmarkSubscribeRSS Feed
JisangYu
Calcite | Level 5

Hello, 

I am a novice SAS programmer assisting research project, and I need help with data manipulation.

My data is as follows:

KISStockNameSum2000Sum2001Sum2002Sum2003Sum2004Sum2005Sum2006Sum2007Sum2008Sum2009
000292059210AA0000000000
000442039020BB0009440790007340220001093304000320309000167460000001699003000
000671036480CC0000000000
001097039230DD0000000000

 

I want to manipulate the data to look like as follows:

KISStockNameSum
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000292059210AA0
000442039020BB0
000442039020BB0
000442039020BB0
000442039020BB944079000
000442039020BB734022000 
000442039020BB1093304000
000442039020BB320309000
000442039020BB1674600000
000442039020BB0
000442039020BB1699003000
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0
000671036480CC0

In short words, after AA's Sum for Years 2000-2009 ends, then BB's Sum for Years 2000-2009 follows, and CC's Sum for Years 2000-2009 follows, and so on.

 

Could anyone provide SAS code for doing this?

It seems like I have to use proc transpose to do this, but I don't know how to duplicate rows along with proc transpose.

Since there are thousands of firms, I really need help with coding.

I'd highly appreciate anyone's help!

1 REPLY 1
ballardw
Super User

Please explain how this is any different than the question you asked in https://communities.sas.com/t5/SAS-Programming/Transposing-column-data-to-create-duplicate-rows/m-p/...

 

And why the proposed solutions weren't helpful. The first proposed solution would require exactly one character change to get this output.

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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