Hi: My COBOL days are long behind me. However, in SAS, when you read data (whether with a SET statement or an INFILE statement), SAS reads the INPUT file or data set one observation or "record" at a time, over and over again, in an implied loop until the end of file marker or end of data set marker is reached. We would normally discourage the use of "GO TO" type of logic or statements for explicitly forcing a read, unless you had advanced or unusual circumstances. For example, in the program below, SASHELP.CLASS is a data set that has 19 records or observations. I want to calculate the projected height in 5 years, and age in 5 years for each of the 19 students. So, in my program, the combination of DATA statement and SET statement instructs SAS to start reading and loading data from the "top" of the file, deal with the first manipulation, creating the HT_IN_5 and AGE_IN_5 variables, and then at the end of the program (before the RUN statement), I have an explicit OUTPUT statement, which causes SAS to write the record. After SAS is done processing that first observation and writing it to the new WORK.ALLSTUDENTS data set, SAS asks whether there are any more observations in the file....well, SASHELP.CLASS has 19 observations and SAS has only finished with the first observation, so it is NOT the end of SASHELP.CLASS and there ARE more observations in the input data set, so SAS goes back and automatically loads the second observation into a "buffer" area called the Program Data Vector. Then, SAS operates on the second observation and outputs it to the new data set. Then, this process continues until all the observations are loaded, manipulated and output to the new data set. In this way, you can see that the DATA step program operates like an "implicit" loop. If you run the program below, you will see how the original file (SASHELP.CLASS) compares to the newly created file (WORK.ALLSTUDENTS). I did not need to force SAS to go through the observations in SASHELP.CLASS -- that happened automatically. A very good description of the DATA step and implied loop is this paper by Ian Whitlock (http://www2.sas.com/proceedings/sugi31/246-31.pdf). If you like flowcharts, this documentation topic (http://support.sas.com/documentation/cdl/en/lrcon/62753/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm), entitled "Overview of Data Step Processing" contains a chart that shows the flow of action in a DATA step program. And, this (http://listserv.uga.edu/cgi-bin/wa?A2=ind9906d&L=sas-l&P=9399) older SAS-L post contains a chart that shows the differences between various COBOL statements and SAS statements. My only quibble with the post is that the quotes apparently got displayed incorrectly so where you see something like ?A?, I believe it was meant to show either 'A' or "A" (in other words, ? characters should be ' or "). cynthia ods listing close; ods html file='c:\temp\original_table.html'; proc print data=sashelp.class; title '1) Original TABLE SASHELP.CLASS'; run; ods html close; data allstudents(keep=name age height age_in_5 ht_in_5); set sashelp.class; ** calculate height in 5 years; ** based on growing 10%; age_in_5 = age + 5; ht_in_5 = height * 1.10; output allstudents; run; ods html file='c:\temp\new_table.html'; proc print data=allstudents; title '2) New Table with New Variables'; run; ods html close;
... View more