Can you please tell me which one of the below options is the answer for the question
Consider the following SAS log:
229 data sasuser.ranch sasuser.condo / view = sasuser.ranch;
230 set sasuser.houses;
231 if style ='RANCH' then output sasuser.ranch;
232 else if style = 'CONDO'then output sasuser.condo;
233 run;
NOTE: DATA STEP view saved on file SASUSER.RANCH
NOTE: A stored DATA STEP view cannot run under a different operating system.
235 proc print data= sasuser.condo;
ERROR: File SASUSER.CONDO.DATA does not exist.
236 run;
NOTE: The SAS System stopped processing this step because of errors.
Which one of the following explains why the PRINT procedure fails?
A. SASUSER.CONDO is a stored DATA step program.
B. A SAS data file and SAS data view cannot be created in the same DATA step.
C. A second VIEW=SASUSER.CONDO option was omitted on the DATA statement.
D. The view SASUSER.RANCH must be processed before SASUSER.CONDO is created.
However, when I tried similar code, as shown below, I didn't get an error message. CONDO.DATA was created. Very confusing. Would you like to help me?
data condo_ranch;
infile datalines dsd;
input style $ sqfeet saledate : date9.;
datalines;
RANCH,1250,10MAR2004
CONDO,1400,17JUN2004
RANCH,1500,20JAN2004
;
data ranch condo /view=ranch;
set condo_ranch;
if style='CONDO' then output condo;
else if style='RANCH' then output ranch;
run;
proc print data=condo;
run;
Hi
The answer is 'D'.
Without you asking and me doing some testing I would have got it wrong and answered 'B'. You wouldn't define anything else than "data table /view=table;" in a real life scenario and until now I wasn't aware that anything else is even possible.
Think of a view as pre-compiled code which gets executed in the moment when you use it (so for example in a SET statement).
What I never realised so far is that this also means for a data step view that you can have more than one output table. I always thought that a data step view is kept in memory and kind-of "streamed" into the data step where its used. But clearly using the code you've posted when actually executing the view using a SET statement table work.condo gets created as well.
I'm sure there will be some special case where such behaviour comes in handy - but it will need a LOT of in-program comment because such behaviour is rather exotic.
Thanks
Patrick
Here some code showing what's going on:
proc datasets lib=work kill nowarn nolist;
quit;
data condo_ranch;
infile datalines dsd;
input style $ sqfeet saledate : date9.;
datalines;
RANCH,1250,10MAR2004
CONDO,1400,17JUN2004
RANCH,1500,20JAN2004
;
data ranch condo /view=ranch;
set condo_ranch;
if style='CONDO' then
output condo;
else if style='RANCH' then
output ranch;
run;
data view=work.ranch;
describe;
run;
title "Tables in WORK before executing the view";
proc sql;
select memname,memtype from dictionary.tables where libname='WORK'
;
quit;
data _null_;
set work.ranch;
run;
title "Tables in WORK after executing the view";
proc sql;
select memname,memtype from dictionary.tables where libname='WORK'
;
quit;
Post your log, with above code submitted.
Hi
The answer is 'D'.
Without you asking and me doing some testing I would have got it wrong and answered 'B'. You wouldn't define anything else than "data table /view=table;" in a real life scenario and until now I wasn't aware that anything else is even possible.
Think of a view as pre-compiled code which gets executed in the moment when you use it (so for example in a SET statement).
What I never realised so far is that this also means for a data step view that you can have more than one output table. I always thought that a data step view is kept in memory and kind-of "streamed" into the data step where its used. But clearly using the code you've posted when actually executing the view using a SET statement table work.condo gets created as well.
I'm sure there will be some special case where such behaviour comes in handy - but it will need a LOT of in-program comment because such behaviour is rather exotic.
Thanks
Patrick
Here some code showing what's going on:
proc datasets lib=work kill nowarn nolist;
quit;
data condo_ranch;
infile datalines dsd;
input style $ sqfeet saledate : date9.;
datalines;
RANCH,1250,10MAR2004
CONDO,1400,17JUN2004
RANCH,1500,20JAN2004
;
data ranch condo /view=ranch;
set condo_ranch;
if style='CONDO' then
output condo;
else if style='RANCH' then
output ranch;
run;
data view=work.ranch;
describe;
run;
title "Tables in WORK before executing the view";
proc sql;
select memname,memtype from dictionary.tables where libname='WORK'
;
quit;
data _null_;
set work.ranch;
run;
title "Tables in WORK after executing the view";
proc sql;
select memname,memtype from dictionary.tables where libname='WORK'
;
quit;
Not so strange there is even an example.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.