BookmarkSubscribeRSS Feed
Ashwini
Calcite | Level 5

Kindly explain difference between option and function.

Regards,

Ashwini

2 REPLIES 2
art297
Opal | Level 21

You may need to explain more.  Typically, in SAS, a function is a mnemonic followed by a left and right parenthesis that may have to contain a value.  Functions return a value.

Options, on the other hand, are settings you may want to control for various procs and statements

Cynthia_sas
Diamond | Level 26

And, to build on what Art said.

Functions can only be used in a limited set of places--typically a DATA step program or a %SYSFUNC call. As Art says, functions return a value, usually (but not always) from an argument, as defined in the function documentation. You can write your own functions using PROC FCMP. Here's a simple example of some functions:

data newclass;

  set sashelp.class;

  fakenum = sum(age,height,weight);

  fakemax = max(age,height,weight);

  date = today();

run;

  

proc print data=newclass;

format date mmddyy10.;

run;

In the above program, SUM, MAX and TODAY are all function calls. SUM and MAX have more than one argument. TODAY is a function that will return the current day, it needs the parentheses, but does not need any arguments.

Options alter some setting (system or procedure or statement) behavior. Options can be global system options, specified in an OPTIONS statement. Or, for some procedures, options can be placed directly on a statement, or sometimes they are placed in parentheses. Sometimes options take the form option=value, but sometimes an option can be a single word. For example:

options orientation=portrait center nodate nonumber;

    

proc report data=sashelp.class nowd split='*' spanrows;

The OPTIONS statement is a global statement that is explicitly setting certain global option settings. In the OPTIONS statement, CENTER, NODATE, and NONUMBER are single word option specifications; while ORIENTATION=PORTRAIT is an option=value pair. For the PROC REPORT statement, NOWD and SPANROWS are single word statement-level options, while DATA=SASHELP.CLASS and SPLIT='*' are statement-level option=value pairs.

  

cynthia

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3891 views
  • 2 likes
  • 3 in conversation