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

Given the SAS data set PRICES:
PRICES
Prodid priceproducttypesalesreturns
K1255.10NETWORK152
B132S 2.34HARDWARE30010
R18KY2 1.29SOFTWARE255
3KL8BY 6.37HARDWARE12515

DY65DW 5.60HARDWARE455

DGTY23 4.55HARDWARE672
The following SAS program is submitted:
data hware inter cheap;
set prices(keep = productype price);
if producttype = ‘HARDWARE’ then output hware; else if producttype = ‘NETWORK’
then output
inter; if price le 5.00;
run;

 

How many observations does the HWARE data set contain?

Ans is 4. 

 

I know there are 4 obs with Hardware, but will the "if price le 5.00" affects the answer? causing only those hardware with price le 5.00 get selected and change the answer to 2 observations. Please help, thanks!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

You put the IF PRICE aafter the OUTPUT statement, therefor it will not affect the results and you get 4 obs.

 

If you change the code so that IF PRICE preceeds the OUTPUT statement it will affect it.

View solution in original post

1 REPLY 1
Shmuel
Garnet | Level 18

You put the IF PRICE aafter the OUTPUT statement, therefor it will not affect the results and you get 4 obs.

 

If you change the code so that IF PRICE preceeds the OUTPUT statement it will affect it.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2236 views
  • 2 likes
  • 2 in conversation