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

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 2975 views
  • 2 likes
  • 3 in conversation