BookmarkSubscribeRSS Feed
wpg_unc
Fluorite | Level 6

It would be helpful to have concatenation on the IDLABEL statement. At the moment it only allows variables like:

IDLABEL alergy_variable; * where 'alergy_variable' may be 'Milk', 'Beef', or whatever the value of the variable is; 

 

However the IDLABEL statement is for 'labeling' so it would be nice if the statement would allow for better dynamic labeling like so:

IDLABEL cat("Do you think you have a food alergy to...",alergy_variable);
5 REPLIES 5
ballardw
Super User

Simple, create the variable with the label you want before proc transpose.

wpg_unc
Fluorite | Level 6

Thanks but I wanted to avoid manually entering a long list of variable names before I run PROC TRANSPOSE.  It would save some time to simply be able to do the concatenation within PROC TRANSPOSE.

ballardw
Super User

@wpg_unc wrote:

Thanks but I wanted to avoid manually entering a long list of variable names before I run PROC TRANSPOSE.  It would save some time to simply be able to do the concatenation within PROC TRANSPOSE.


Possibly this comment is because you are unfamiliar with some of the less known functions such as VNAME and the use of arrays.

This creates a not terribly fancy variable to hold text build in the fashion you describe.

 

data example;
   set sashelp.class (obs=1);
   array n _numeric_;
   array c _character_;
   length Idvar $ 100;
   do i=1 to dim(n);
      idvar = catx(" ","This is the label for variable",vname(n[i]));
      output;
   end;
   do i=1 to dim(c);
      idvar = catx(" ","This is the label for variable",vname(c[i]));
      output;
   end;
   keep idvar;
run;

But since you have posted 1) no starting data, 2) no actual desired result and 3) have not even bothered to name the procedure this is supposed to modify (it's lucky you weren't trying to do something to ID has many procedures have ID statements) it is hard to provide a more targeted response.

 

 

Since IDLABEL is designed to point to a VARIABLE not an explicit text value this would be a very extreme departure from the existing behavior. Perhaps if you declared appropriate LABELS when the data were originally created a double transpose might help here. But no example data ....

Reeza
Super User

Suggestions for improvements or modifications can be made in SAS Ballotware section here:

https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas

 

 

As indicated however, this is relatively easy to work around, you can add a previous step that creates the variable as desired in the data set. Another option, if you want it in one step is to use VALIDVARNAME=ANY, then you can have the actual variable labelled as 'My long text label' and list them in ID statement as well. There's the DELIM option to add a separator for the ID variables. 

 


@wpg_unc wrote:

It would be helpful to have concatenation on the IDLABEL statement. At the moment it only allows variables like:

IDLABEL alergy_variable; * where 'alergy_variable' may be 'Milk', 'Beef', or whatever the value of the variable is; 

 

However the IDLABEL statement is for 'labeling' so it would be nice if the statement would allow for better dynamic labeling like so:

IDLABEL cat("Do you think you have a food alergy to...",alergy_variable);

 

 

wpg_unc
Fluorite | Level 6

I submitted this question as a feature request.

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
  • 5 replies
  • 521 views
  • 2 likes
  • 3 in conversation