BookmarkSubscribeRSS Feed
y658li
Calcite | Level 5

Hello I have data like this:

Large Corporate - CCAR Scenario   
Q2-2020 dataq1q2q3
I-1123
I-2456
I-3789
US Commercial - CCAR Scenario   
Q2-2020 dataq1q2q3
I-1123
I-2456
I-3789

 

And I want to change my table like this:

SectorFROM_RISK_RATINGscenario_dateMIGRATION_PROB_D
CorporateI-1Q2-20201
CorporateI-2Q2-20202
CorporateI-3Q2-20203
CorporateI-1Q2-20204
CorporateI-2Q2-20205
CorporateI-3Q2-20206
CorporateI-1Q2-20207
CorporateI-2Q2-20208
CorporateI-3Q2-20209
CommercialI-1Q2-20201
CommercialI-2Q2-20202
CommercialI-3Q2-20203
CommercialI-1Q2-20204
CommercialI-2Q2-20205
CommercialI-3Q2-20206
CommercialI-1Q2-20207
CommercialI-2Q2-20208
CommercialI-3Q2-20209

 

How can I change the format in SAS? Thanks!

 

6 REPLIES 6
ballardw
Super User

What file type is the data for the "have" data?

y658li
Calcite | Level 5

already transferred as sas data, used to be in excel

ballardw
Super User

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

 

y658li
Calcite | Level 5

however, my original data is larger than this, so I need to transpose the original data 

y658li
Calcite | Level 5

I've attached a file for further explanation. So the original file is in excel and I want to import it into SAS and make the format as the desired tab.

ballardw
Super User

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Subset your data an use the macro to create an example data set using the link I posted earlier.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 904 views
  • 0 likes
  • 2 in conversation