BookmarkSubscribeRSS Feed
Quartz | Level 8



I have a categorical variable (e.g., Race) in a sav dataset. Race has multiple levels and is coded as 1, 2, 3, etc. Each level has a label, e.g., White, Asian, etc. When I run proc freq in SAS, the table displays only the labels but not numerical codes. Is there a way to display both numerical codes and labels?


I want to recode the variable, and for that I need to see which number corresponds to which label (i.e., that 1 is White, that 2 is Hispanic, etc.). And I am not sure how to do that unless I open the file in SPSS.


Thank you in advance.

Opal | Level 21

Given that you already have the labeled version, try adding this to your PROC FREQ:


format race;


That should give you the unlabeled version, so you can match them up.


Note that there doesn't have to be a one-to-one match.  It is conceivable that the labeling combines two numeric values into a single category.

Quartz | Level 8

That helps! Thank you!


I can match them up since my data is not very complex. But one can potentially have more complex coding with multiple numeric codes labeled in the same way or the number of cases per group can be the same, which will complicate the matching process. So, there is no way to see the coding schema in SAS directly?

Opal | Level 21

Yes, but you need to know a bit about where the pieces get saved.


SAS saves the translations as a format.  If you know the location of the formats, you can set up a LIBNAME statement to identify the location.  Assuming you define "mylib" within the LIBNAME statement, you could then use:


proc format library=mylib fmtlib;



That should print all the translations you would ever want to see.

Super User

If you export your data from SPSS you have an option to create a format file. Those formats can then be applied to the SAS dataset. 


Older version but think it still applies



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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