SUM function

Reply
New Contributor
Posts: 2

SUM function

Hello,

I am using following codes for getting row wise sum. My concern is that why I am getting different values for variable 'Tot_Price' in both the codes.


code 1:

data c2;

set sashelp.pricedata;

Tot_Price=sum(of price1--price17);

run;

code 2:

data c2;

set sashelp.pricedata;

Tot_Price=sum(of priceSmiley Happy;

run;

Since, I am beginner in SAS, please help me.

Thanks in Advance!

Kinjal

Trusted Advisor
Posts: 1,931

Re: SUM function

Posted in reply to KinjalkumarPatel

Becase code 2 include variable price, while code 1 does not include variable price.

By the way, in code 1, you'd be better off with price1-price17 instead of price1--price17, which could include other variables you don't want (not the case here, but maybe in some other cases)

New Contributor
Posts: 2

Re: SUM function

Posted in reply to PaigeMiller

Oopps...I haven't notice that variable 'Price' is present in the data. By the way, thanks for the answer.

Ask a Question
Discussion stats
  • 2 replies
  • 169 views
  • 2 likes
  • 2 in conversation