BookmarkSubscribeRSS Feed
deleted_user
Not applicable
what is the significant of the 'OF'in x=sum(OF a1-a4,a6,a9);
7 REPLIES 7
data_null__
Jade | Level 19
It is the "signal" for the following is a "SAS Variable List". Without it the argument is A1 minus A4.

Look a documentation for "SAS Variable Lists". Message was edited by: data _null_;
deleted_user
Not applicable
I go through the sas document but i could not able to get it.
so please explain me.

thanks in advance.
deleted_user
Not applicable
can you explain me what is a "signal"?
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
In this context, the use of "signal" simply means this technique is using a SAS programming/code argument "OF" and when coded as shown it is treated differently than a more typical SUM(...) function execution.

Scott Barry
SBBWorks, Inc.

Google advanced search argument, this topic/post:

sum function site:sas.com

-> generated several results, including the link below were "OF" is explained in the SUM function documentation:

SAS Language Reference: Dictionary, SUM Function:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000245953.htm
BW
Calcite | Level 5 BW
Calcite | Level 5
a refers to an array
a1 is the first element of the array
sum(a1,a2,a3,a4) can be shorted handed to sum(of a1-a4)
hope that answer your question
Cynthia_sas
SAS Super FREQ
Hi:
As a teacher, I am honor bound to add some SAS-related elaboration to the post about A1-A4 as being in ARRAY A.

In some languages, the list of variables or fields named A1-A4 WOULD automatically be an array reference to the array named A. And the array named A would, in some languages, be a physical data construct.

In SAS, however, an ARRAY is not a physical data construct. The name of the array is declared in an ARRAY statement (either in a DATA step program or in some of the STAT procedures that allow ARRAY references) and does not have to bear any relationship at all to the numbered (or unnumbered) variable list that defines the array members.

So, for example, these are all valid ARRAY declarations in a SAS DATA step program (for numeric variables):
[pre]
array a a1-a4;
array wombat a1-a4;
array unord a3 a1 a4 a2;
array lovelucy fred ethel lucy ricky;
[/pre]

Only the first ARRAY statement declares the variable name to be 'A'. In the above ARRAY statements, the references point to the following variables:
[pre]
Array Array Refers to
Name Reference SAS Variable
-------- ----------- -----------
A A(2) A2
WOMBAT WOMBAT(2) A2
UNORD UNORD(2) A1
LOVELUCY LOVELUCY(2) ETHEL
[/pre]

When a SAS dataset is not actively being used in a DATA step program, you will never see the declared array NAME (A, WOMBAT, UNORD, or LOVELUCY) in the descriptor portion of the SAS dataset (as with a PROC CONTENTS or a PROC DATASETS). You -will- see the variables, ALL the variables, in the descriptor portion of the dataset.

So, if your dataset contains numbered variables, such as A1, A2, A3, A4 or YR1999, YR2000, YR2001, YR2002, it sometimes becomes tedious to list all the variables one after the other in code. Many SAS statements, functions and options allow you to use variable lists (in a variety of forms), as shown in the documentation, as a referencing shortcut.

For example, if you use the SUM function, the use of 'OF' in the SUM function, as described here:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000245953.htm

You could have:
[pre]
total = sum(a1, a2, a3, a4);
OR
total = sum(lucy, ricky, fred, ethel);
OR
total = sum(OF a1-a4);
OR
total=sum(OF a1-a4, a5, a6);
[/pre]

IF you had declared an ARRAY in a DATA step program, you might use a DO loop to accumulate or create a new variable from the members of an array. However, the original question was about the SUM function, so I'll end here. The bottom line is that numbered variables do not automatically mean that the numbered variables are in an ARRAY -- that is frequently one usage of numbered variables -- but not an automatic usage.

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
  • 7 replies
  • 1293 views
  • 0 likes
  • 5 in conversation