The SASDATA.BANKS data set has five observations when the following SAS program is submitted:
libname sasdata 'SAS-data-library';
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
How many observations will the ALLOBS data set contain?
A. 5
B. 15
C. 20
D. 25
Click Comment link to get answer
'D'
ReplyDeleteroshini ur right baby
DeleteAnswer is 'D'
ReplyDeletei think its C....2000 to 2020 by 5. so, 4 iterations..
ReplyDeleteD
ReplyDeleteyear=2000 to 2020 by 5
(includes the 2020 also, so 5 iterations)
D
ReplyDelete2000
2005
2010 2015
2020
'A'
ReplyDeleteD
ReplyDelete5*5=25
D
ReplyDelete5 observations 5 iterations
A is correct answer
ReplyDeleted
ReplyDeleteA
ReplyDeleteD
ReplyDeletebecause the output statement is inside the do loop, an observation will be created each time through the loop, so 5 observations, 5 loops, 25 observations total
ReplyDeleteanswers IS A.
ReplyDeleteBecause of output statement 5 observations are created otherwise only one.
try the below SAS statement:-
data allobs;
rate=0.1;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
end;
run;
Answer is D.
ReplyDeletedata banks;
input num;
datalines;
1
2
3
4
5
;
run;
data allobs;
set banks;
rate=0.1;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
NOTE: There were 5 observations read from the data set WORK.BANKS.
NOTE: The data set WORK.ALLOBS has 25 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
@ sweta,
ReplyDeleteu missed d the explicit ouptput statement in the do loop. due to this explicit output staemnt in the do loop there will be 5 obsn for each obsn in the bank dataset, so the total of obsn in the new dataset allobs will be (5*5)=25
>> joydeep786@gmail.com
hi im just confused why 5 iteration for each obs? i know its bcuz of the output in the do loop......but is it bczu of the by 5 or sth so that each obs get 5 output?
Deleteans is D its a good one .
ReplyDeletemy mail
lotlikar.aniket44@gmail.com
Why are you guys giving out your email ids?? I don't anyone is interested in mailing dudes. Girls are most welcome to share their emails please. That behavior is highly encouraged.
ReplyDeleteAnswer is D. A good question after a long while.
Shouldn't the answer be A?
ReplyDeletecorrrect me if i'm wrong, but
it's INOCREMENTED by 5.
so 2000, 2005, 2010, 2015, 2020 (total of 5)
for those who argue that it's 5obs*5iterarion
isn't that the case when it's NESTED DO LOOP?
correct me if i'm wrong.
Thx in advance.
Ans is A....
ReplyDeleteplz dont post without cross checking the ans...it will be confusing
try this code :
data allobs;
rate = 0.5;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
proc print ;
run;
There was question and answer sheet on web it says 25 but trying to find why 25?
ReplyDeleteSAScert;
Can you give us the reasons for adding datelines;
1
2
3
4
5
; why we need this ?
Because increment by 5 thefefore we added 5 datalines?
Dude question says, dataset bank has 5 observations. If you take only one observation then A will be r8.
DeleteD is right,we r copying one data set to another dataset.there were 5 observations and for each obs the loop runs one time. so for one obs it will take 5 iterations .... for better understanding use macros with MLOGIC option ....
ReplyDeletethank u
Chiru
why 5 iterations for each obs.....bcuz of the by 5?
DeleteD is the right answer.
ReplyDeletethe do loop will execute 5 times(2000,2005,2010,2015,2020)for each observation of the sasdata.banks data set.
therefore,
=5(observation of sasdata.bank)*5(times do loop execution)
=25 !!
why 5 times for each obs? not 1 or some different number?
DeleteAnyone who said anything other than D is wrong. Please try this code:
ReplyDeleteData employee;
input id salary name$ location$12.;
cards;
101 8500 asim bangalore
102 45 ravi chennai
103 75236 chinna hyderabad
104 899 siva US
107 675 rajesh hubli
run;
data allobs;
set employee;
rate=0.1;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
Remove the output statement or put the output outside the do look. The allobs dataset will have 5 observations.
why rate 0.1
Deletea
ReplyDeleteAns is 5 its sad by 5 means every tme ts increment by 5 so only 5 observaton.
ReplyDeleteAns : D
ReplyDeleteExample :
data banks;
input rate;
datalines;
0.1
0.2
0.3
0.4
0.5
;
run;
data allobs;
set banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
Proc Print;
run;
Log :
145
146 data banks;
147 input rate;
148 datalines;
NOTE: The data set WORK.BANKS has 5 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.01 seconds
154 ;
155 run;
156
157 data allobs;
158 set banks;
159 capital=0;
160 do year = 2000 to 2020 by 5;
161 capital + ((capital+2000) * rate);
162 output;
163 end;
164 run;
NOTE: There were 5 observations read from the data set WORK.BANKS.
NOTE: The data set WORK.ALLOBS has 25 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.13 seconds
cpu time 0.04 seconds
165
166 Proc Print;
167 run;
NOTE: Writing HTML Body file: sashtml3.htm
NOTE: There were 25 observations read from the data set WORK.ALLOBS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.12 seconds
cpu time 0.01 seconds
Out Put :
ReplyDeleteObs rate capital year
1 0.1 200.00 2000
2 0.1 420.00 2005
3 0.1 662.00 2010
4 0.1 928.20 2015
5 0.1 1221.02 2020
6 0.2 400.00 2000
7 0.2 880.00 2005
8 0.2 1456.00 2010
9 0.2 2147.20 2015
10 0.2 2976.64 2020
11 0.3 600.00 2000
12 0.3 1380.00 2005
13 0.3 2394.00 2010
14 0.3 3712.20 2015
15 0.3 5425.86 2020
16 0.4 800.00 2000
17 0.4 1920.00 2005
18 0.4 3488.00 2010
19 0.4 5683.20 2015
20 0.4 8756.48 2020
21 0.5 1000.00 2000
22 0.5 2500.00 2005
23 0.5 4750.00 2010
24 0.5 8125.00 2015
25 0.5 13187.50 2020
Answer A. Proper answer: Depends on rate.
ReplyDelete@Zakku, why do you have five observations for rate? Not one or six? If we choose six observations for rate, the answer would be 30.
In my view, we can assume a unique value for rate; the answer would be five (A).
what wa the answer?? why 25??
ReplyDelete5 observations from input dataset, each observation is outputted 5 times by do loop, so 5*5 = 25 obs.
Deletesorry all but im just confused why is it 5 iteration for each obs bcuz of the output in do loop; not a different number of iteration?
ReplyDeleteAn understanding of PDV can clear the doubts of all who are confused. Ans is D
ReplyDelete
ReplyDeleteTHE CORRECT ANSWERS IS A..
RUN THE BELOW MENTIONED CODING AND YOU WILL GET THE ANSWER
IF THE OUTPUT IS OUTSIDE THE LOOP ONLY ONE OBSERVATION COMES OUT.
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
36 data allobs;
37
38 capital=0;
39 do year = 2000 to 2020 by 5;
40 capital + ((capital+2000) * rate);
41 output;
42 end;
43 run;
NOTE: Variable rate is uninitialized.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
5 at 40:27
NOTE: The data set WORK.ALLOBS has 5 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.06 seconds
remove the set statement from it it will still give the same no of iterations
ReplyDeleteans is d.
ReplyDeleteTry this code
proc sql;
create table work.banks (
rate integer,
Var2 varchar(30));
insert into work.banks values (10, 'one');
insert into work.banks values (20, 'two');
insert into work.banks values (1, 'three');
insert into work.banks values (4, 'four');
insert into work.banks values (8, 'five');
quit;
data allobs;
set work.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
If you read the question again carefully, u can see '~has five observations'. So 5(five observations)*5(from do loop)=25
ReplyDeleteReally cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info!
ReplyDeleteSAS Online Training
R Programming Online Training|
Tableau Online Training|
Such an ideal piece of blog. It’s quite interesting to read content
ReplyDeletelike this. I appreciate your blog Tableau Online Training
The JSM (Friday-Saturday-Sunday) Alfamart promo has been published, but is valid until Tuesday next week. Yes, this JSM Alfamart promo lasts for a long period, namely 7-9 August 2020. Who knows, the items in the JSM Alfamart promo catalog are suitable for your needs. Alfamart is one of the leading minimarket networks, regularly publishing JSM promo price catalogs for its customers. If you are one of the many customers who are waiting for the JSM Alfamart promo catalog, here are some items in the JSM Alfamart promo catalog that you can look at. Also Read: Fun! There is a special Dufan entrance ticket promo for independence The JSM Alfamart promo catalog is an opportunity for customers to get daily necessities at lower prices than usual. In fact, some people make the JSM Alfamart promo catalog a wholesaler of goods to be sold again. However, of course, there is nothing wrong with comparing the JSM Alfamart promo catalog with promo prices from other minimarkets, including the nearest neighboring stalls. JSM Alfamart promo prices and other modern minimarket JSM promo programs are not the only factors that can be considered shopping. Also Read: 'Two Weekly' Hypermart Promo for August 6 - 19 2020, just released! Being able to bargain and be able to chat with sellers is sometimes a valuable reason to beat price promos when shopping for household needs. Well, we can only get all of that from the nearest shops that are open in our neighborhood.
ReplyDelete