DATA Step, Macro, Functions and more

For SAS Base PROC FORMAT?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

For SAS Base PROC FORMAT?

Is PROC FORMAT statement GLOBAL statement?

Because, we can use value statement in any data step statement.

 

Thank You.


Accepted Solutions
Solution
‎04-15-2018 12:37 PM
SAS Super FREQ
Posts: 9,371

Re: For SAS Base PROC FORMAT?

[ Edited ]

Hi: Just a clarification. Once you define a user-defined FORMAT, using a VALUE, INVALUE or PICTURE statement, within a PROC FORMAT step, you can use the format NAME on a FORMAT statement within a DATA step program. However, you cannot use a VALUE statement in a DATA step program, as shown below:

 

value_data_step.png

 


However, when you define a format within a PROC FORMAT step, as shown below:

 

value_used_correctly.png

Then you CAN use a FORMAT statement to associate the format name with a specific variable in your program.

Cynthia

View solution in original post


All Replies
Super User
Posts: 13,583

Re: For SAS Base PROC FORMAT?

Posted in reply to kishangabani

The answer might be a sort of "maybe".

The LIBRARY option on a proc format statement indicates where a format may be stored. If Library is not specified then that would be the WORK library.

You have a SAS option call FMTSEARCH which tells SAS where to search for formats and the order to search the libraries.

This code will show the current setting you have as a Log entry:

proc options option=fmtsearch;run;

 

You use the Options statement to assign or modify the FMTSEARCH order such as

options fmtsearch=(WORK SASHELP OLDLIB);  would assign these three libraries to the search path.

Options append(fmtsearch= NewLIb); would add NEWLIB to the end of the current FMTSEARCH order, Insert would place it at the beginning of the search order.

 

If you specify a library on the PROC Format statement and do not add it to the FMTSEARCH path then the formats there cannot be found. If the library is not assigned at the time the format is used then the format cannot be found.

 

One proc format creates a format in a library on the current fmtsearch path the format may be used anywhere in the SAS session.

 

With the default library of WORK and WORK almost always in the FMTSEARCH option then formats are generally available as long as the Proc Format code is run in every session.

 

All this stuff related to libraries is because some organizations have many custom formats and creating permanent formats in a known location users can reference means they do not have to run the code to recreate all of the formats in each session. These organization also usually have settings in the SAS set up to set the FMTSEARCH to reference the libraries.

Solution
‎04-15-2018 12:37 PM
SAS Super FREQ
Posts: 9,371

Re: For SAS Base PROC FORMAT?

[ Edited ]

Hi: Just a clarification. Once you define a user-defined FORMAT, using a VALUE, INVALUE or PICTURE statement, within a PROC FORMAT step, you can use the format NAME on a FORMAT statement within a DATA step program. However, you cannot use a VALUE statement in a DATA step program, as shown below:

 

value_data_step.png

 


However, when you define a format within a PROC FORMAT step, as shown below:

 

value_used_correctly.png

Then you CAN use a FORMAT statement to associate the format name with a specific variable in your program.

Cynthia

Occasional Contributor
Posts: 6

Re: For SAS Base PROC FORMAT?

Posted in reply to Cynthia_sas

Hi, again

I understand. 

so, PROC FORMAT statement, in VALUE stat.

 

We can use any of the SAS dataset or file in SAS any session. Just run, PROC FORMAT stat. and use any where we want.

 

Thank You.

SAS Super FREQ
Posts: 9,371

Re: For SAS Base PROC FORMAT?

Posted in reply to kishangabani
Hmm. Well I would say that you use a VALUE statement in a PROC FORMAT step. What you define with a VALUE statement is a user-defined format. You can use this format in a FORMAT statement in any procedure step that uses formats and in DATA step programs.

We cover many of these concepts in our Programming 1 class, which is free as self-paced e-learning.

Cynthia
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 174 views
  • 3 likes
  • 3 in conversation