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

Is PROC FORMAT statement GLOBAL statement?

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

 

Thank You.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

4 REPLIES 4
ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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

kishangabani
Obsidian | Level 7

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.

Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 1768 views
  • 3 likes
  • 3 in conversation