Proc Transpose idlabel is not printed by Proc Print

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Proc Transpose idlabel is not printed by Proc Print

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


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 23,776

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to Leonard32

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


All Replies
Super User
Posts: 23,776

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to Leonard32

What does the log show for that code?

PROC Star
Posts: 1,844

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to Leonard32

You are missing the ID statement 

 

IDLABEL Statement


Creates labels for the transposed variables.

Restriction:Must appear after an ID statement.
New Contributor
Posts: 4

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to novinosrin

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. 

Super User
Posts: 23,776

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to Leonard32

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. 


 

 

Solution
2 weeks ago
Super User
Posts: 23,776

Re: Proc Transpose idlabel is not printed by Proc Print

Posted in reply to Leonard32

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. 


 

PROC Star
Posts: 1,844

Re: Proc Transpose idlabel is not printed by Proc Print

[ Edited ]
Posted in reply to Leonard32

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;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 85 views
  • 6 likes
  • 3 in conversation