turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- problem using SUM function in sas

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-14-2014 12:31 PM

data mydata ;

input score1_score3;

sum ( of score1-score3)= s;

datalines;

23 36 .

23 67 89

. . .

21 . 43

22 32 78

;

run;

I made up this data set , which resembles my real data problem with using sum function and got following error. I don't understand it, I checked sas documentation and examples. This is the way sas has given examples to find sum of entries in variables. Why is this not working????? what is meant by the following error.

7173 data mydata ;

7174 input score1_score3;

7175 sum ( of score1-score3)= s;

ERROR: **Undeclared array referenced: sum.**

**ERROR: Variable sum has not been declared as an array.**

7176 datalines;

Accepted Solutions

Solution

11-14-2014
12:37 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ruhi

11-14-2014 12:37 PM

Possible typo: score1_score3 resulting in single variable, score1 - score 3 likely intended. If this is what executed then the variables score1 through score3 were not created.

Order of expression:

s = sum (of scor1 - score3); The receiving value MUST be on the left of the =. Basically the construct variablename() = value is reserved for arrays.

All Replies

Solution

11-14-2014
12:37 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ruhi

11-14-2014 12:37 PM

Possible typo: score1_score3 resulting in single variable, score1 - score 3 likely intended. If this is what executed then the variables score1 through score3 were not created.

Order of expression:

s = sum (of scor1 - score3); The receiving value MUST be on the left of the =. Basically the construct variablename() = value is reserved for arrays.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

11-14-2014 12:44 PM

data mydata;

infile datalines missover;

input score1 score2 score3;

s=sum(of score1-score3);

datalines;

23 36 .

23 67 89

. . .

21 . 43

22 32 78

;

run;