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!!!
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.