a week ago - last edited a week ago
Quick (hopefully simple) question
I have the below data as table name "GC_SGRP_BREAKOUT"
HSHLD_NO SGRP_DSCR SPEND_TY
00010005 SPECIALITY GIFT CARDS 25
00010005 HOME GIFT CARDS 50
00010005 FASHION GIFT CARDS 50
00010005 RESTAURANTS GIFT CARDS 105
Basically I want it to read as this :
HSHLD_NO SPECIALITY HOME FASHION RESTAURANTS
00010005 25 50 50 105
How do i make this happen in SAS?
Thank you in advance,
a week ago
If you don't know how to find examples for a procedure in the documentation, that's a good thing to learn. Navigate to the procedure name and then it has a section/tab titled Examples. There's usually the most basic case, which is yours, and then more advanced examples as well. Here's a few links to get you started.
UCLA walk through
LexJansen.com search results
a week ago
For a beginner, PROC TRANSPOSE is not easy. In this case, it's harder because you have to prepare your data before PROC TRANSPOSE can be applied. Two simple preparatory steps ...
First, create a variable holding the names to be used after transposing:
varname = scan(sgrp_dscr, 1);
You can take a look at VARNAME, and expect to use it in an ID statement within PROC TRANSPOSE.
Second, sort your data (if it's not already sorted):
proc sort data=partway_there;
This permits you to use a BY statement within PROC TRANSPOSE.
Finally, head into the PROC TRANSPOSE:
proc transpose data=partway_there out=want;
You will have to add to that final TRANSPOSE to get it to function the way you would like.