04-13-2018
danielhanbitlee
Calcite | Level 5
Member since
01-19-2018
- 20 Posts
- 0 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by danielhanbitlee
Subject Views Posted 7085 04-06-2018 02:01 PM 7096 04-06-2018 03:10 AM 565 04-05-2018 07:39 PM 7137 04-05-2018 05:33 PM 601 04-05-2018 05:26 PM 7146 04-05-2018 05:24 PM 7153 04-05-2018 03:35 PM 7218 04-04-2018 08:04 PM 7222 04-04-2018 08:03 PM 7252 04-04-2018 07:06 PM -
Activity Feed for danielhanbitlee
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-06-2018 02:01 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-06-2018 03:10 AM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-05-2018 07:39 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-05-2018 05:33 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-05-2018 05:26 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-05-2018 05:24 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-05-2018 03:35 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-04-2018 08:04 PM
- Posted Re: set statement in a do loop vs set statement not in do loop on SAS Programming. 04-04-2018 08:03 PM
- Posted set statement in a do loop vs set statement not in do loop on SAS Programming. 04-04-2018 07:06 PM
- Posted Re: Need Help Reading Column into Date Format on SAS Programming. 03-22-2018 03:35 PM
- Posted Need Help Reading Column into Date Format on SAS Programming. 03-22-2018 02:30 AM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 01:20 PM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 12:45 PM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 12:40 PM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 12:05 PM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 11:53 AM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-02-2018 11:18 AM
- Posted Re: ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-01-2018 11:14 PM
- Posted ERROR: File MEDICAL.LESIONS.DATA does not exist. on SAS Programming. 02-01-2018 10:13 PM
04-06-2018
02:01 PM
Got it. Makes more sense now. Thank you so much!
... View more
04-06-2018
03:10 AM
Thank you for the response. I think I'm beginning to understand better. So, just to make sure, let me try to explain. I will use the code that you gave previously, except I won't drop the variable "year" from the do loop: data banks;
input name : $ 13. rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
fourthbank 0.05
;
run;
data newbank;
do year=1 to 3;
set banks;
output;
end;
run; Output: Obs year name rate
1 1 FirstCapital 0.0718
2 2 DirectBank 0.0721
3 3 VirtualDirect 0.0728
4 1 fourthbank 0.0500 Here's my explanation of what is going on (also I have a question in red font color😞 1. First iteration of data step First iteration of do loop (year = 1) First observation of the dataset is read and output is given (code: set banks; output;) Second iteration of do loop (year = 2) Second observation of the dataset is read and output is given (code: set banks; output;) Third iteration of do loop (year = 3) Third observation of the dataset is read and output is given (code: set banks; output;) End of do loop and end of first iteration of data step 2. Second iteration of data step First iteration of do loop (year = 1) Fourth observation of the dataset is read and output is given (code: set banks; output;) How does SAS know to read the fourth observation of the input dataset here? Is there some sort of a pointer? End of file reached. EOF = 1 Second iteration of do loop (year = 2) Terminate data step because EOF = 1. No output is given Please correct/clarify.
... View more
04-05-2018
07:39 PM
Thank you for the exercise. This is a good point and it helps me to understand what is going on behind the scenes when combining datasets.
... View more
04-05-2018
05:33 PM
I see. Thank you for this as this is a good exercise. My explanation is that the do loop will go from year = 1 to year = 3 by 1s. In addition to this, there's the implicit loop of the data step. This will read the input dataset one observation at a time until the end of the dataset. Since there are four observations, the output dataset will also have four observations even though the do loop only goes from 1 to 3. So, even though the set statement is inside a do loop, the set statement will be controlled by the implicit data step loop. That is, all the observations in the set statement will only be read once. Please correct/clarify my understanding as you see fit.
... View more
04-05-2018
05:26 PM
Thank you for the reply. This is very helpful. I would accept this as a solution as well but I'm not sure how to have multiple answers as solutions.
... View more
04-05-2018
05:24 PM
Thank you for the thorough response. It is very helpful. From all your examples, I am beginning to understand that there are two different loops going on in #1. That is, first, there's one loop for the do loop (year = 1 to year = 3). And then, second, there's the implicit loop of the data step. This reads all the observations in the input dataset (from the set statement) independent of the do loop. Please correct/clarify if my understanding is wrong. Otherwise, this has been very helpful. Thanks again.
... View more
04-05-2018
03:35 PM
Ah got it. That was helpful. Thank you again! I would accept this as a solution as well but I'm not sure how to have multiple answers as solutions.
... View more
04-04-2018
08:04 PM
Also, can you resend the pdf link? It doesn't seem to work for me.
... View more
04-04-2018
08:03 PM
I see. What about in the first code block? Don't I have the data set open three times as well since the set statement is inside a DO loop?
... View more
04-04-2018
07:06 PM
I have the following dataset: data banks;
input name : $ 13. rate;
datalines;
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
;
run; I am comparing between two blocks of codes. First code block: data newbank (drop = year);
do year=1 to 3;
set banks;
output;
end;
run;
proc print data = newbank;
run; Output to first code block: Obs name rate
1 FirstCapital 0.0718
2 DirectBank 0.0721
3 VirtualDirect 0.0728 Second code block: data newbank;
set banks;
output;
set banks;
output;
set banks;
output;
run;
proc print data = newbank;
run; Output to second code block: Obs name rate
1 FirstCapital 0.0718
2 FirstCapital 0.0718
3 FirstCapital 0.0718
4 DirectBank 0.0721
5 DirectBank 0.0721
6 DirectBank 0.0721
7 VirtualDirect 0.0728
8 VirtualDirect 0.0728
9 VirtualDirect 0.0728 Question: Why doesn't the first code block have the same output as the second code block? Why is there a difference if I use a set statement in a do loop vs using a set statement not in a do loop?
... View more
03-22-2018
03:35 PM
Awesome! Thank you!
... View more
03-22-2018
02:30 AM
Can someone help me read the DATE variable as a DATE7. format? I failed so I am just reading it as character format. The code is below. I am using SAS University Edition. Thanks. data sasuser.amounts;
input Name $1-12 EmpID 14-18 Date $20-26 Amt 28-29;
datalines;
ANKERTON, L. 11123 08OCT16 92
ANKERTON, L. 11123 15OCT16 43
DAVIS, R. 22298 04OCT16 16
MASTERS, T. 33351 13OCT16 18
MASTERS, T. 33351 27
THOMAS, A. 21OCT16 15
WOLMER, B. 44483
;
... View more
02-02-2018
01:20 PM
I see. Thank you for helping me out on this. I sent you an email just now. Best, Daniel
... View more
02-02-2018
12:45 PM
And the second part of the page that has medical.lesions code.
... View more
02-02-2018
12:40 PM
I am using SAS Studio University Edition. It's the latest one, so SAS 9.4? I attached a screenshot of the page that references medical.lesions.
... View more