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

Hello,

 

I am trying to read the names of a categorical variable in SAS and change it.

Is there any predefined function to extract variable levels in SAS ? 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
PROC FREQ.

PROC FREQ DATA=sashelp.class;
TABLE age / OUT= want;
RUN;

The output is displayed and in the WANT data set. Change the variables in lower case to match your requirements.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
proc sql;
     select distinct variablename from have;
quit;
--
Paige Miller
KarimaTouati
Obsidian | Level 7

Thank you PaigeMiller, I am looking for each level of my categorical variable and not an extraction of specific variables in my dataset.

PaigeMiller
Diamond | Level 26

@KarimaTouati wrote:

Thank you PaigeMiller, I am looking for each level of my categorical variable and not an extraction of specific variables in my dataset.


The solution I gave does what you ask for.

--
Paige Miller
Reeza
Super User
PROC FREQ.

PROC FREQ DATA=sashelp.class;
TABLE age / OUT= want;
RUN;

The output is displayed and in the WANT data set. Change the variables in lower case to match your requirements.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4822 views
  • 1 like
  • 3 in conversation