Hi,
when using PROC TRANSPOSE with the IDLABEL option, SAS refuses to print those labels when using PROC PRINT with the LABEL option. Does anyone has a clue? Is it because the length of the variable 'Attribute_name' is more then 32?
options label;
proc transpose data=data_in out=test;
by user_id metadata_user_id;
var attribute_value;
idlabel attribute_name;
run;
proc print data=test label; run;
Thanks in advance!
Kind regards,
Leonard
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/
Create an enumeration of VAR1-VAR### using the approach above and the CATS function.
@Leonard32 wrote:
That is kind of the essence of the problem. I'm not able to use the ID statement, because the names of the variables have length > 32. Some names are almost identical, but become unique after position 32, SAS isn't able to distinguish the variables and SAS complains that for example for one variable:
The ID value "'tr.car.bhvr.accel_h.non_motorway'n" occurs twice in the same BY group.
So I want to overcome this problem by using the labels instead of the names. I think labels aren't limited to 32 characters?
I could start renaming the variables ... but we are talking about data sets with more than 1.000 variables. So that is not feasible.
What does the log show for that code?
You are missing the ID statement
IDLABEL Statement
Creates labels for the transposed variables.
Restriction: | Must appear after an ID statement. |
That is kind of the essence of the problem. I'm not able to use the ID statement, because the names of the variables have length > 32. Some names are almost identical, but become unique after position 32, SAS isn't able to distinguish the variables and SAS complains that for example for one variable:
The ID value "'tr.car.bhvr.accel_h.non_motorway'n" occurs twice in the same BY group.
So I want to overcome this problem by using the labels instead of the names. I think labels aren't limited to 32 characters?
I could start renaming the variables ... but we are talking about data sets with more than 1.000 variables. So that is not feasible.
Make it up. Since you're not using it's irrelevant, so make a variable or number that uniquely identifies the values and then the labels are what is displayed.
@Leonard32 wrote:
That is kind of the essence of the problem. I'm not able to use the ID statement, because the names of the variables have length > 32. Some names are almost identical, but become unique after position 32, SAS isn't able to distinguish the variables and SAS complains that for example for one variable:
The ID value "'tr.car.bhvr.accel_h.non_motorway'n" occurs twice in the same BY group.
So I want to overcome this problem by using the labels instead of the names. I think labels aren't limited to 32 characters?
I could start renaming the variables ... but we are talking about data sets with more than 1.000 variables. So that is not feasible.
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/
Create an enumeration of VAR1-VAR### using the approach above and the CATS function.
@Leonard32 wrote:
That is kind of the essence of the problem. I'm not able to use the ID statement, because the names of the variables have length > 32. Some names are almost identical, but become unique after position 32, SAS isn't able to distinguish the variables and SAS complains that for example for one variable:
The ID value "'tr.car.bhvr.accel_h.non_motorway'n" occurs twice in the same BY group.
So I want to overcome this problem by using the labels instead of the names. I think labels aren't limited to 32 characters?
I could start renaming the variables ... but we are talking about data sets with more than 1.000 variables. So that is not feasible.
use a concatenated approach
something like
proc transpose data=data_in out=test delim='_';
by user_id metadata_user_id;
var attribute_value;
id attr_id attribute_name;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.