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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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