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

I am working with a dataset that contains more than 100 different categorical variables, some with up to 10 possible categories. The data manager provides separate .DAT files with labels for each category, using the following structure:

 

data format;
input label $ formatname $ type $ code;
datalines;
Not reported RESULT N 999
Positive RESULT N 1
Negative RESULT N 2
Missing RESULT N .
Small SIZE N 1
Medium SIZE N 2
Large SIZE N 3
Missing SIZE N .
...

I'm able to import these .DAT files to create a format datasets as follows:

PROC IMPORT OUT= formats (RENAME=(VAR1=LABEL VAR2=FMTNAME VAR3=TYPE VAR4=CODE))
			DATAFILE="C:\\..."
            DBMS=TAB REPLACE;
     GETNAMES=no;  
     DATAROW=1; 
RUN;

Is there a way to apply all labels in this formats dataset to the dataset I'm using for the project, without manually writing each entry using proc format?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You can create a format from a data set.
An example and some basic details are here:
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1e19y6lrektafn1kj6nbvhus59w.htm

And if you're not sure how to structure your data set, make a small example using proc format and then have it saved to a data set using the CNTLOUT option.

View solution in original post

1 REPLY 1
Reeza
Super User
You can create a format from a data set.
An example and some basic details are here:
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1e19y6lrektafn1kj6nbvhus59w.htm

And if you're not sure how to structure your data set, make a small example using proc format and then have it saved to a data set using the CNTLOUT option.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 752 views
  • 1 like
  • 2 in conversation