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.

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

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