DATA Step, Macro, Functions and more

Assigning user defined format to variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

Assigning user defined format to variables

Hi,

 

I am trying to associate the permanently saved user defined formats in data step with the dataset from sashelp.cars;

 

created the format as below-

 

PROC FORMAT LIBRARY=SDTM.FRMT1;
 VALUE MSRPFMT
  0-<20000="CHEAP AND BEST"
  20000-<40000="AFFORDABLE"
  40000-HIGH="LUXURY";
 RUN;

 

PROC FORMAT LIBRARY=SDTM.FRMT1;
 VALUE $ORIGINFMT
  "Asia"="PART'S FROM ASIA"
  "USA"="ASSEMBLED IN USA"
  "Europe"="VALIDATED IN EUROPE";

RUN;

 

to assign the format in data step-

 

DATA CARS ;
SET SASHELP.CARS (OBS=10) ;
FORMAT MSRP MSRPFMT. ORIGIN ORIGINFMT.;
RUN;

 

the log says-

 

ERROR 48-59: The format MSRPFMT was not found or could not be loaded.

62 ! FORMAT MSRP MSRPFMT. ORIGIN ORIGINFMT.;
                                 ----------
                                 48
ERROR 48-59: The format $ORIGINFMT was not found or could not be loaded.

63   RUN;

 

could someone help in finding what did i miss in the code?

 

Thanks

Eram

 


Accepted Solutions
Solution
‎08-14-2017 06:37 PM
Super User
Posts: 5,518

Re: Assigning user defined format to variables

You'll need a slightly more complex statement:

 

OPTIONS FMTSEARCH=(SDTM.FRMT1);

 

The default name of the format catalog (if you were to specify SDTM only) is FORMATS, not FRMT1.

View solution in original post


All Replies
Super User
Posts: 5,441

Re: Assigning user defined format to variables

You need the dollar sign in the format name when you assign it as well.

Be sure to point out your format location with FMTSEARCH global option.

Data never sleeps
Occasional Contributor
Posts: 11

Re: Assigning user defined format to variables

updated the code as sggested with option= fmtsearch and $ sign in format name as -

OPTIONS FMTSEARCH=FRMT1;
DATA CARS;
SET SASHELP.CARS;
FORMAT MSRP MSRP. ORIGIN $ORIGINFMT.;
RUN;

 

 

log still says error-

DATA CARS;
SET SASHELP.CARS;
FORMAT MSRP MSRP. ORIGIN $ORIGINFMT.;
                 -----
                 48
ERROR 48-59: The format MSRP was not found or could not be loaded.

181! FORMAT MSRP MSRP. ORIGIN $ORIGINFMT.;
                              -----------
                              48
ERROR 48-59: The format $ORIGINFMT was not found or could not be loaded.

182  RUN;

Super User
Posts: 10,046

Re: Assigning user defined format to variables

OPTIONS FMTSEARCH=(SDTM) ;
Solution
‎08-14-2017 06:37 PM
Super User
Posts: 5,518

Re: Assigning user defined format to variables

You'll need a slightly more complex statement:

 

OPTIONS FMTSEARCH=(SDTM.FRMT1);

 

The default name of the format catalog (if you were to specify SDTM only) is FORMATS, not FRMT1.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 71 views
  • 1 like
  • 4 in conversation