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

I'm trying to create a user defined format as follows, but I'm not seing the updated Format in the dataset dis_entity_id. Am I doing something wrong? In my final dataset I want to see the texts as 'Schaden/Unall' if the ENTITY_ID is 5801

 

proc format;
Value $ENTIT
'5801'='Schaden/Unall'
'60011'='Hestia'
'56002'='Lebn'
'60041'='Austria'
'6002'='Belgien'
'5401'='Köln'
'54009'='Segros'
'5400'='Belgen'
'test'='NULL';
run;

proc sql;
create table dis_entity_id as select distinct ENTITY_ID format=$ENTIT. from &_INPUT;
quit;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Your code is logically correct so either your data is not what you think it is or you have an error somewhere else. It could be as simple as you opening the input data set instead of the output data set or some other issue. What happens if you run a proc freq on the data with the format instead?

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Are there error messages in the log?

Is ENTITY_ID a character variable?

Does PROC CONTENTS show the expected format attached to variable ENTITY_ID?

What do you see in the data set? (SHOW US)

--
Paige Miller
Babloo
Rhodochrosite | Level 12

No error Messages in the log.

yes, ENTITY_ID is a character variable

 

Log says

 

NOTE: Format $ENTIT has been output.
PaigeMiller
Diamond | Level 26

@Babloo wrote:

No error Messages in the log.

yes, ENTITY_ID is a character variable

 

Log says

 

NOTE: Format $ENTIT has been output.

Please provide the answers to all the questions I asked.

--
Paige Miller
ballardw
Super User

@Babloo wrote:

 In my final dataset I want to see the texts as 'Schaden/Unall' if the ENTITY_ID is 5801

 

 

 


And how are you "looking" at your data set dis_entity_id?

Babloo
Rhodochrosite | Level 12
Just opening the dataset in SAS EG after the execution of program.

Do you feel that my code is logically correct?
Reeza
Super User
Your code is logically correct so either your data is not what you think it is or you have an error somewhere else. It could be as simple as you opening the input data set instead of the output data set or some other issue. What happens if you run a proc freq on the data with the format instead?

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
  • 6 replies
  • 840 views
  • 4 likes
  • 4 in conversation