BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Leonard32
Fluorite | Level 6

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?

 

c1.PNG

 

 

 

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;

c2.PNG

 

Thanks in advance!

Kind regards,

Leonard

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 


 

View solution in original post

6 REPLIES 6
Reeza
Super User

What does the log show for that code?

novinosrin
Tourmaline | Level 20

You are missing the ID statement 

 

IDLABEL Statement


Creates labels for the transposed variables.

Restriction:Must appear after an ID statement.
Leonard32
Fluorite | Level 6

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. 

Reeza
Super User

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. 


 

 

Reeza
Super User

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. 


 

novinosrin
Tourmaline | Level 20

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1052 views
  • 6 likes
  • 3 in conversation