BookmarkSubscribeRSS Feed
gandikk
Obsidian | Level 7

Hi,

 

I have a requirement on custom transpose. I have duplicate account numbers (Column 1) and it’s corresponding indicators (Column 2). I have to transpose the indicators in the way they are mentioned in Column3.  For Example, rows 1, 8, 15, 22 and 23 have plain indicators. So, in column3, those indicators alone should be transposed for the corresponding Account numbers. Rows 2, 9 and 16 have M indicators. So, those rows should get all the M indicators with commas in between.

Can you please let me know whether there is any way to achieve this in SAS?

 

 

Row Column1 Column2 Column3
1 52212227 15 15,23,24,27,30
2 52212227      15 -M 15-M,23-M,24-M
3 52212227      15 -TS 15-TS,23-TS,24-TS
4 52212227      15 -PR 15-PR,23-PR,24-PR
5 52212227      15 -HQPAR 15-HQPAR,23-HQPAR,24-HQPAR
6 52212227      15 -DU 15-DU,23-DU,24-DU
7 52212227      15 -GU 15-GU,23-GU,24-GU
8 52212227 23 15,23,24,27,30
9 52212227      23 -M 15-M,23-M,24-M
10 52212227      23 -TS 15-TS,23-TS,24-TS
11 52212227      23 -PR 15-PR,23-PR,24-PR
12 52212227      23 -HQPAR 15-HQPAR,23-HQPAR,24-HQPAR
13 52212227      23 -DU 15-DU,23-DU,24-DU
14 52212227      23 -GU 15-GU,23-GU,24-GU
15 52212227 24 15,23,24,27,30
16 52212227      24 -M 15-M,23-M,24-M
17 52212227      24 -TS 15-TS,23-TS,24-TS
18 52212227      24 -PR 15-PR,23-PR,24-PR
19 52212227      24 -HQPAR 15-HQPAR,23-HQPAR,24-HQPAR
20 52212227      24 -DU 15-DU,23-DU,24-DU
21 52212227      24 -GU 15-GU,23-GU,24-GU
22 52212227 27 15,23,24,27,30
23 52212227 30 15,23,24,27,30

 

SAS@EMMAUS
1 REPLY 1
art297
Opal | Level 21

I would just create a new variable, using the anyalpha function, and include that with your other by variable. e.g.,

 

data need;
  set have;
  char=anyalpha(column3)>0;
run;

Art, CEO, AnalystFinder.com

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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