I am having trouble creating a dataset using information in 2 other data sets: intervals and accounts. Basically I want to break down data from the accounts dataset based on the intervals in the intervals dataset to create a 3rd dataset which has each account and it's interval name listed.
THanks! -- would it be possible for you to provide an example? I see the syntax for do-while loops but I am not sure how I would code the condition to loop until the end of the data set. So, I would have something like this right...
keep interval acc# bal1 bal2;
do until (last row of the intervals table)
if bal1 > min1 & bal1min2 & bal2
then interval = grpnm;
In the above, how would I specify that I want to iterate on rows in the intervals dataset. how would I specify that when I meet the if condition, I should include the row in the new dummy dataset and use the value of grpnm from intervals at the particular row i stopped?
The Proc SQL solution is better and more elegant. I hadn't thought through the problem enough to realize that the implicit cartesian join was actually desirable in this case.
To do the loop, you need to read about the set command and the dataset options.
You can use multiple sets in a data step, so you would place one inside the loop, and one outside the loop. The one inside the loop would have to have the appropriate options set to capture the end of the file (end=eof). I'm not sure how to reset back to the beginning. You may need to use random access, requesting the observation specifically by number.
But, I wouldn't waste any time on the looping methodology.