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
- /
- General Programming
- /
- unable to understand output values of variables

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

07-02-2015 07:01 AM

Dear SAS users,

Could you please help me understand output of below program?

data work.passengers1;

if origpassengers = . then origpassengers =100;

transpassengers = 100;

origpassengers = totlapassengers = sum( origpassengers, transpassengers) + 0 ;

run;

proc print data = work.passengers1;

title 'check-1';

run;

output is:

origpassengers =0

transpassengers =100

totlapassengers = .

What i understand is that when pdv initialize all variables to missing, then we get first condition tset to true, hence origpassenger =100, then transpas is set to 100, but then how come value of totalpass is coming out to be missing (.) and why origpass has been set to 0.

Appreciate your help as always

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

07-02-2015 07:08 AM

again, i just realised that totalpass value should also have been 200 instead of 100. Please explain with bit detail.

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

07-02-2015 07:46 AM

I don't understand what you are trying to do here but this is where your problem is:

origpassengers = totlapassengers = sum( origpassengers, transpassengers) + 0 ;

If you give an example of data and your desired solution I can help more.

data step1;

infile cards;

input orig ;

cards;

.

500

2

160

;

run;

data passengers1;

set step1;

if orig = . then orig =100;

trans = 100;

total = sum( orig, trans);

run;

If you are adding the original in hopes to sum that's different, let me if this helps.

data passengers2;

set step1;

if orig = . then orig =100;

trans = 100;

total = sum(orig,trans);

sum + total;

run;

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

07-02-2015 09:53 AM

It is a problem i came through while preparing for base sas certification, so I am not bringing this problem from any practicle reference / problem. But, I concede that there is some important concept which I am missing and I need to understand that.