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

Hi! I am new to sas and I am trying to do the proc freq and format. I put my format in a seperate file but when I use in the main file it doesn't work in the proc freq.

This is what I put in the format file 

proc format library=work.bili;
value sex 0="Male"
		  1="Female";
value cholvs 0="Missing value"
		     1="Normal"
		     2="High"
proc freq data=analysis;
	table sex cholvs;
	format sex sex. cholvs cholvs.;
run;

Screen Shot 2020-09-19 at 5.33.54 AM.pngAnd the results still looks like this..

I am wondering if there is anyting I did wrong? Thanks for any hints!

1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11

You told SAS to store the format in a catalog using the library= option.

 

You now must update the SAS session settings so the catalog will be searched when the system is looking for a custom format.

options fmtsearch=(work library work.bili);

proc freq data=have;
	table sex cholvs;
	format sex sex. cholvs cholvs.;
run;

The FMTSEARCH option only needs to be set once per session.  The code for that can be placed in your autoexec.sas or at the top of a program file.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Are there ERRORs or WARNINGs in the LOG?

 

Show us the entire LOG (in other words, show us the code, the ERRORs , the WARNINGs and the NOTEs as they appear in the log) for these two steps (PROC FORMAT and PROC FREQ) by copying the log as text and pasting it into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.

--
Paige Miller
mxccc
Calcite | Level 5
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc format library=work.bili;
 74         
 75         value status 1="Death"
 76          2="Transplantation"
 77          3="Censored";
 NOTE: Format STATUS has been written to WORK.BILI.
 78         
 79         value drug 1="D-penicillamine"
 80            2="placebo";
 NOTE: Format DRUG has been written to WORK.BILI.
 81         
 82         value sex 0="Male"
 83           1="Female";
 NOTE: Format SEX has been written to WORK.BILI.
 84         
 85         value ascites 0="No"
 86               1="Yes";
 NOTE: Format ASCITES has been written to WORK.BILI.
 87         
 88         value hepatomegaly 0="No"
 89                  1="Yes";
 NOTE: Format HEPATOMEGALY has been written to WORK.BILI.
 90               
 91         value spiders 0="No"
 92               1="Yes";
 NOTE: Format SPIDERS has been written to WORK.BILI.
 93         
 94         value edema 0="No edema and no diuretic therapy for edema"
 95         0.5="Edema present without diuretics, or edema resolved by diuretics"
 96         1="Edema despite diuretic therapy";
 NOTE: Format EDEMA has been written to WORK.BILI.
 97         value cholvs 0="Missing value"
 98              1="Normal"
 99              2="High"
 100        run;
 NOTE: Format CHOLVS has been written to WORK.BILI.
 101        
 102        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 114      

Thanks for the promt reply! There is no ERRORs or WARNINGs in the log but only note. The above is the entire log for my seperate format file and the above is the note related to the issues.

Screen Shot 2020-09-19 at 6.13.07 AM.png

I don't know why this happens..I though I did create formats and store them in the work library using the code in the format file...

RichardDeVen
Barite | Level 11

You told SAS to store the format in a catalog using the library= option.

 

You now must update the SAS session settings so the catalog will be searched when the system is looking for a custom format.

options fmtsearch=(work library work.bili);

proc freq data=have;
	table sex cholvs;
	format sex sex. cholvs cholvs.;
run;

The FMTSEARCH option only needs to be set once per session.  The code for that can be placed in your autoexec.sas or at the top of a program file.

mxccc
Calcite | Level 5
Thank you so much!! It works!

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
  • 4 replies
  • 612 views
  • 1 like
  • 3 in conversation