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

Hello all,

 

I have a large dataset in which I would like to change the label names of multiple columns to match the variable names. For example, I have 5 variables named new_diag_1, new_diag_2, new_diag_3, new_diag_4, new_diag_5. When I run a proc contents I see that the labels for each of these 5 variables is just new_diag. I would like the label to be the same as the variable name for each new_diag_1-5 variable.

Note: In my actual dataset I have about 10-20 more variables that I will need to change the labels to match the variable names (some of the var names will have the same prefixes, e.g., new_treatment_1-5, new_dr_1-5, etc.)

 

I know I can rename each label by writing it out like the code below but I'm wondering if there's an easier way to change the name for multiple labels with the same prefixes. Any help is appreciated!

proc sql;
	create table want as 
		select new_diag_1 label = 'new_diag_1'
	from have;
run;
quit;
1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1
Reeza
Super User
Just remove the labels of all? Then they display with variable names instead?

attrib _all_ label = ' ';

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n0k88cst84603rn12cu4dq3l3mv0.htm#n0k88cs...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 753 views
  • 1 like
  • 2 in conversation