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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 4149 views
  • 1 like
  • 3 in conversation