I'm trying to automate a process.
My incoming dataset has a single row per customer and has many X-variables tied to a Yes or No if the customer has purchased the product.
I need to Transpose the data but I run into the 32 character limitation in PROC TRANSPOSE. I've forced the variables to be less than 32characters but wonder if there's a way to circumvent this challenge and keep the original long variable names.
CustomerNum Product1 Product2 ProductHasaVariableNamethatiswelloverthe32byterestrictioninTranspose
1234567 Yes No Yes
SAS Names are limited to 32 bytes.
However you can use the IDLABEL statement in PROC TRANSPOSE to create a variable LABEL from a string that is much longer.
If you can't figure it post some sample data. Including an example of what you have is always helpful.
Please explain. SAS variable names can't be more than 32 characters long. It's not just a proc transpose restriction.
First do you even need to transpose the data at all? What are you doing with it? Perhaps you can analyze it in a the original tall-skinny format.
Second the variable NAME cannot be longer than 32, but you could use the product name as the LABEL instead.
data have ;
length CustomerNum $20 Product $200 Status $3 ;
input CustomerNum Product Status ;
cards;
1234567 Product1 Yes
1234567 Product2 No
1234567 ProductHasaVariableNamethatiswelloverthe32byterestrictioninTranspose Yes
ABCDEF Product2 Yes
;;;;
proc sort ;
by product ;
run;
data have2 ;
do until (last.product);
set have ;
by product ;
_name_='VAR'||put(_n_,Z4.) ;
output;
end;
run;
proc sort ;
by customernum _name_ ;
run;
proc transpose data=have2 out=want (drop=_name_) ;
by customernum ;
id _name_;
idlabel product ;
var status ;
run;
proc print;
run;
proc print label ;
run;
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!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.