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-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
  • 1 reply
  • 1967 views
  • 2 likes
  • 2 in conversation