BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

What is the way to label the following variables during proc transpose .

Label of variable Wealth1 will be  Stocks wealth1

Label of variable Wealth2 will be  Stocks wealth2

Label of variable Wealth3 will be  Stocks wealth3

Label of variable Wealth4 will be  Stocks wealth4

Label of variable Wealth5 will be  Stocks wealth15

 

Data have;
label wealth='Stocks wealth';
input CustID month wealth;
cards;
1 2101 10
1 2102 20
1 2103 30
1 2104 40
1 2105 50
2 2101 5
2 2102 10
2 2103 15
2 2104 20
2 2105 25
;
Run;
proc transpose data=have  out=Want (drop=_name_ ) prefix=wealth;
VAR wealth ;
BY CustID ;
Run;
8 REPLIES 8
Ronein
Meteorite | Level 14

Thanks, however during transpose from long to wide there is no need to use ID statement.

What is the way to add the labels?

Kurt_Bremser
Super User

@Ronein wrote:

Thanks, however during transpose from long to wide there is no need to use ID statement.

What is the way to add the labels?


The IDLABEL statement.

So you need to create the labels first.

PaigeMiller
Diamond | Level 26

After all this time, with @Kurt_Bremser and myself and others constantly advising you to avoid wide data sets, I am surprised that you keep using wide data sets. The best thing to do would be to leave the data as long, and then programming is sooooo much easier.

--
Paige Miller
Ronein
Meteorite | Level 14

I need to prepare a data panel with one row per customer and from this panel will create reports in Tableu.

This is the reason for wide structure.

Do you still think that it is wrong (for using panel)?

ChrisNZ
Tourmaline | Level 20

Can't Tableau create reports from long data? I'd be surprised.

Just supply Tableau with the long data -prepared as needed- and let Tableau present it.

Sajid01
Meteorite | Level 14

Modify your prefix in proc transpose as follows

proc transpose data=have  out=Want (drop=_name_  _LABEL_) prefix='Stocks Wealth'n;
VAR wealth ;
BY CustID ;
Run;

Your output will be like this

Sajid01_0-1624813468117.png

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 793 views
  • 2 likes
  • 5 in conversation