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

I created and user defined format but when I run data step to apply format the log reads Format $disf was not found or could not be loaded. I am using SAS University Edition. Engine V9. Below is the full code. Any ideas will be appreciated.

 

 

libname abc "/folders/myfolders/xyz";

 

Proc import datafile="/folders/myfolders/xyz/document.xlsx"

out=doc1

dbms=xlsx;

run;

 

proc format;

value disf 0='No' 1='Yes';

run;

 

data doc2; set doc1;

format diseased disf.;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Ok so add a $ to format name and try again

proc format;

value $disf 0='No' 1='Yes';

run;

 

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

You need to examine your dataset doc1 thoroughly and properly. Your code works fine for my example:

 

proc format;

value disf 0='No' 1='Yes';

run;

 

data w;
do i=1 to 10;
 do j=0 to 1;
output;
end;
end;
format j disf.;
drop i;
run;

PaigeMiller
Diamond | Level 26

Is the variable DISEASED numeric or character?

--
Paige Miller
amin1234
Obsidian | Level 7

It's a character variable. 

novinosrin
Tourmaline | Level 20

Ok so add a $ to format name and try again

proc format;

value $disf 0='No' 1='Yes';

run;

 

ballardw
Super User

@novinosrin wrote:

Ok so add a $ to format name and try again

proc format;

value $disf 0='No' 1='Yes';

run;

 


AND use the new format:

data doc2; set doc1;

format diseased $disf.;

run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 6776 views
  • 0 likes
  • 4 in conversation