DATA Step, Macro, Functions and more

difference between function and option

Frequent Contributor
Posts: 76

difference between function and option

Kindly explain difference between option and function.



Posts: 7,363

difference between function and option

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

Posts: 8,743

Re: difference between function and option

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();



proc print data=newclass;

format date mmddyy10.;


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.



Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation