I want to use the nliteral function to rename a variable into the label, however, I need to parse the label. Is it possible to combine the nliteral with the scan function, or if not is there a workaround?
@SAS_Muggle wrote:
I want to use the nliteral function to rename a variable into the label, however, I need to parse the label. Is it possible to combine the nliteral with the scan function, or if not is there a workaround?
I cannot figure out what you mean. You only need to apply the NLITERAL() function to the value once you have decided what you want it to be. Finish all of your "parsing" before you get to the step of generating the new name.
data want;
set have;
length new_name $64 ;
* generate new_name from LABEL ;
new_name=substr(coalesce(label,name),1,32);
* Now make it an name literal ;
new_name = nliteral(new_name);
run;
Please provide an actual example and the desired result.
I am afraid that "rename a variable" in this context is very likely going to be difficult if your label has any length at all. Even with the generally ugly and awkward to use name literals you are still limited to 32 characters for the variable name.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: