BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pchen002
Obsidian | Level 7
The following SAS program is submitted:
data work.passengers;
if OrigPassengers = . then 
OrigPassengers = 100;
TransPassengers = 100;
OrigPassengers = .;
TotalPassengers = sum (OrigPassengers, TransPassengers) +0;
run;
What is the value of the TOTALPASSENGERS variable in the output data set?
 
Answer is 100, why not 200??
Please help, thanks!!!
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Statements within the DATA step execute in order.  Leaving out TransPassengers from the analysis, that means:

 

(1) set OrigPassengers to 100

(2) set OrigPassenters to .

(3) compute TotalPassengers

 

At the time TotalPassengers is computed, OrigPassengers is missing.

View solution in original post

7 REPLIES 7
Norman21
Lapis Lazuli | Level 10

Missing + 100 + 0 = 100

 

If you move your IF statement further down, the answer will be 200.

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

pchen002
Obsidian | Level 7
Thank you!
Astounding
PROC Star

Statements within the DATA step execute in order.  Leaving out TransPassengers from the analysis, that means:

 

(1) set OrigPassengers to 100

(2) set OrigPassenters to .

(3) compute TotalPassengers

 

At the time TotalPassengers is computed, OrigPassengers is missing.

pchen002
Obsidian | Level 7
Understood, thank you!!!
Kurt_Bremser
Super User

@pchen002 wrote:
The following SAS program is submitted:
data work.passengers;
if OrigPassengers = . then 
OrigPassengers = 100;
TransPassengers = 100;
OrigPassengers = .;
TotalPassengers = sum (OrigPassengers, TransPassengers) +0;
run;
What is the value of the TOTALPASSENGERS variable in the output data set?
 
Answer is 100, why not 200??
Please help, thanks!!!

Why should it be 200? In the sum() function, missing values are considered zero.

Start reading the f*cking documentation, your continuing questions on extremely simple issues start to reveal you as a person with an allergy to think on your own.

Andygray
Quartz | Level 8

@pchen002  Although this is a open technical forum, Kindly do not consider this as school homework forum or education forum. The spirit of the discussions should be kept interesting for everybody, which means both the original poster as well as for responders. The questions that you post will add really no value to many if not all.

Reeza
Super User

Ok... @Kurt_Bremser  I think there's a bit of piling on here that needs to stop. Not that the point isn't correct but this seems to cross over the considerate/polite boundary. Please remember that you're not required to respond and that's the best way to not support this type of behaviour. And yes, I've done this myself at times, so I do get it 😉

 

 

@pchen002 please use some consideration in your posts. Here's a post that explains how to post good questions https://stackoverflow.com/help/how-to-ask

 

If you're genuinely attempting to learn please show an attempt and you'll find a lot of support and help. But so far, you've posted questions, not responded to follow ups and the questions are literally copy and paste from whatever study material you're using. 

 

And another point - good study material explains the examples/questions and doesn't depend on the free help of others. Consider the SAS certification guide which has fully explained problems and examples. It's worth the small price, or consider checking with your University library or Safari tech books which have the guides. 

 

Good Luck. 

 

 

 

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
  • 2373 views
  • 7 likes
  • 6 in conversation