SlideShare a Scribd company logo
Applications of the DOW LoopApplications of the DOW Loop
Table of Contents
• Introduction
• Structure of DOW Loop
• Application 1: Cartesian Join
• Application 2: Geometric Mean
• Multiple DOW Loop
• Application 3: Bivariate Regression
• Conclusion
Introduction
• A simple data step concept first proposed
by Ian Whitlock on the SAS – L list with
Don Henderson.
• Detail analysis by Paul Dorfman and
Howard Schreier.
• The term DOW (DO – Whitlock) loop was
coined by Dorfman.
Structure of the DOW Loop
• The original DOW loop is a simple do
loop with a set statement in the structure.
Data ... ;
<Stuff done before break-event> ;
Do <Index Specs> Until ( Break-Event ) ;
Set A ;
<Stuff done for each record> ;
End ;
<Stuff done after break-event... > ;
Run ;
Application 1: Cartesian Join
• Cartesian Join is one of the simple things
that can be easily achieved in a single
SQL statement.
PROC SQL;
CREATE TABLE DATA AS SELECT * FROM
A,B;
QUIT;
Application 1: Cartesian Join
• Cartesian Joins can also be done
using a simple DOW loop.
• Not as simple and as elegant as the
SQL statement
• Applicable to all versions of SAS
DATA CART_JOIN;
SET A;
DO J = 1 TO COUNT;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
The engine
A B C D
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
DATA CART_JOIN;
SET A;
DO J = 1 TO 4;
SET B NOBS=COUNT POINT=J;
OUTPUT;
END;
RUN;
Application 2: Geometric Mean
• Most of the mathematical and statistical
functions in SAS are column based and
deriving a calculation for just a single
column can be very troublesome.
• The DOW loop provides a simple
solution to these problems.
• We can use a DOW loop to loop through
the observations and derive the answer.
Application 2: Geometric Mean
/*LOOP RUN*/
DATA _NULL_;
/*SINGLE DO LOOP*/
DO UNTIL (EOF);
SET HAVE END=EOF;
BY CATEGORY;
/*RESETING THE PREVIOUS VALUE*/
IF FIRST.CATEGORY THEN DO;
TOTAL = 1;
COUNT = 0;
END;
/*CALCULATING THE TOTAL SUM AND COUNTS VALUE*/
TOTAL = TOTAL*NUMBER;
COUNT = SUM(COUNT,1);
/*OUTPUTING THE RESULTS AND THE GEOMETRIC MEAN CALCULATION*/
IF LAST.CATEGORY THEN DO;
/*CALCULATION FORMULA AS PER THE INSTRUCTION IN SAS HELP*/
GEOMEAN = TOTAL**(1/COUNT);
/*OUTPUTING THE SOLUTION*/
PUT CATEGORY= GEOMEAN=;
OUTPUT;
END;
END;
RUN;
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
3
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
3 6
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
3 6
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
3 6
4
DATA _NULL_;
DO UNTIL (EOF);
SET A END = EOF;
COUNT = SUM(COUNT,1);
VALUE = SUM(VALUE,A);
END;
RUN;
The engine
A B C D
1 2 3 4
2 2 3 4
3 2 3 4
4 2 3 4
Count Value
1 1
2 3
3 6
4 10
Multiple DOW Loop
• The double DOW loop structure
was first proposed by Howard
Scherier on the SAS – L as a
variation of the original technique.
• There have been several
approaches which use multiple
DOW loops to achieve various
calculations which requires multiple
iterations through the data.
Application 3: Bivariate Regression
• In order to calculate the
parameters of the regression, we
have to first calculate the mean of
both the x and y variables.
• After running through this, we will
then use the mean to calculate the
sum of square for both x-squares
and xy which are essential for the
regression parameter estimation.
Application 3: Bivariate Regression
/******************************************************************************
-------------------------------------------------------------------------------
DOW LOOP REGRESSION
-------------------------------------------------------------------------------
THIS MACRO IS A SIMPLE DEMONSTRATION THE USE OF DOUBLE DOW LOOP TO COMPUTE THE
SLOPE AND INTERCEPT OF A SIMPLE LINEAR REGRESSION MODEL.
-------------------------------------------------------------------------------
INPUT DESCRIPTION
-------------------------------------------------------------------------------
INPUT INPUT DATASET
Y DEPEDENT VARIABLE
X INDEPENDENT VARIABLE
-------------------------------------------------------------------------------
*******************************************************************************/
%LET INPUT = HTWT;
%LET Y = HEIGHT;
%LET X = WEIGHT;
/******************************************************************************/
Application 3: Bivariate Regression
/******************************************************************************
MAIN MACRO
*******************************************************************************/
%MACRO DOW_REG();
/******************************************************************************/
/******************************************************************************
*******************************************************************************/
DATA _NULL_;
/******************************************************************************
FIRST DOW LOOP FOR MEANS CALCULATION SUMMARIZATION
*******************************************************************************/
DO I = 1 BY 1 UNTIL (EOF);
SET &INPUT END=EOF;
SUM_Y = SUM(SUM_Y,&Y);
SUM_X = SUM(SUM_X,&X);
COUNT = SUM(COUNT,1);
END;
/******************************************************************************
MEANS CALCULATION
*******************************************************************************/
MEAN_Y = SUM_Y/COUNT;
MEAN_X = SUM_X/COUNT;
Application 3: Bivariate Regression
/******************************************************************************
LOOP TO CALCULATE SUM OF SQUARES AND XY
*******************************************************************************/
DO _N_ = 1 TO COUNT;
SET &INPUT;
XY = (&Y - MEAN_Y)*(&X - MEAN_X);
XX = (&X - MEAN_X)**2;
SUM_XY = SUM(SUM_XY,XY);
SUM_XX = SUM(SUM_XX,XX);
END;
/******************************************************************************
CALCULATION OF SLOPES
*******************************************************************************/
SLOPE = SUM_XY/SUM_XX;
INTERCEPT = MEAN_Y - SLOPE*MEAN_X;
PUT SLOPE = INTERCEPT = ;
/******************************************************************************
*******************************************************************************/
RUN;
%MEND;
/******************************************************************************
MACRO CALLING
*******************************************************************************/
%DOW_REG();
Conclusion
• One of the most versatile programming
structures in SAS
• Can be used on a variety of scenario to
achieve the required results
• Beside data manipulation, DOW loops
are also useful for summarization of
data, mathematical calculations and
even model parameter estimations.

More Related Content

Similar to Applications of the DOW loop

Plsql
PlsqlPlsql
Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)
Marreddy P
 
Please follow the cod eand comments for description CODE #incl.pdf
Please follow the cod eand comments for description CODE #incl.pdfPlease follow the cod eand comments for description CODE #incl.pdf
Please follow the cod eand comments for description CODE #incl.pdf
annaielectronicsvill
 
Assembler Numerical in system programming
Assembler Numerical in system programmingAssembler Numerical in system programming
Assembler Numerical in system programming
Assembler Numerical in system programming
 
SAS codes and tricks Comprehensive all codes
SAS codes and tricks Comprehensive all codesSAS codes and tricks Comprehensive all codes
SAS codes and tricks Comprehensive all codes
rizrazariz
 
Plsql programs(encrypted)
Plsql programs(encrypted)Plsql programs(encrypted)
Plsql programs(encrypted)
Karunakar Singh Thakur
 
Query Optimization & How to interpret query execution plan
Query Optimization & How to interpret query  execution planQuery Optimization & How to interpret query  execution plan
Query Optimization & How to interpret query execution plan
Amol Barewar
 
SAS codes and tricks Comprehensive all codess
SAS codes and tricks Comprehensive all codessSAS codes and tricks Comprehensive all codess
SAS codes and tricks Comprehensive all codess
rizrazariz
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
MANDHASAIGOUD1
 
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolutionLearning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Vibeesh CS
 
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
Rina Wahyuni
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
Åįjâž Ali
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptx
vamsiyadav39
 
the following SPOOL command will capture the results of .docx
 the following SPOOL command will capture the results of    .docx the following SPOOL command will capture the results of    .docx
the following SPOOL command will capture the results of .docx
MARRY7
 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For Everyone
Daniel Boisvert
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
Vlsi ii project presentation
Vlsi ii project presentationVlsi ii project presentation
Vlsi ii project presentation
Redwan Islam
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouse
Fru Louis
 
ERTS UNIT 3.ppt
ERTS UNIT 3.pptERTS UNIT 3.ppt
ERTS UNIT 3.ppt
Pavithra525349
 
Flight landing Project
Flight landing ProjectFlight landing Project
Flight landing Project
Poorvi Deshpande
 

Similar to Applications of the DOW loop (20)

Plsql
PlsqlPlsql
Plsql
 
Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)Final Case Study Churn (Autosaved)
Final Case Study Churn (Autosaved)
 
Please follow the cod eand comments for description CODE #incl.pdf
Please follow the cod eand comments for description CODE #incl.pdfPlease follow the cod eand comments for description CODE #incl.pdf
Please follow the cod eand comments for description CODE #incl.pdf
 
Assembler Numerical in system programming
Assembler Numerical in system programmingAssembler Numerical in system programming
Assembler Numerical in system programming
 
SAS codes and tricks Comprehensive all codes
SAS codes and tricks Comprehensive all codesSAS codes and tricks Comprehensive all codes
SAS codes and tricks Comprehensive all codes
 
Plsql programs(encrypted)
Plsql programs(encrypted)Plsql programs(encrypted)
Plsql programs(encrypted)
 
Query Optimization & How to interpret query execution plan
Query Optimization & How to interpret query  execution planQuery Optimization & How to interpret query  execution plan
Query Optimization & How to interpret query execution plan
 
SAS codes and tricks Comprehensive all codess
SAS codes and tricks Comprehensive all codessSAS codes and tricks Comprehensive all codess
SAS codes and tricks Comprehensive all codess
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolutionLearning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
 
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
Rina Wahyuni ~ Jual Harga & Detail Total Station Pentax R422 (Single Face) 08...
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptx
 
the following SPOOL command will capture the results of .docx
 the following SPOOL command will capture the results of    .docx the following SPOOL command will capture the results of    .docx
the following SPOOL command will capture the results of .docx
 
Call Execute For Everyone
Call Execute For EveryoneCall Execute For Everyone
Call Execute For Everyone
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
 
Vlsi ii project presentation
Vlsi ii project presentationVlsi ii project presentation
Vlsi ii project presentation
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouse
 
ERTS UNIT 3.ppt
ERTS UNIT 3.pptERTS UNIT 3.ppt
ERTS UNIT 3.ppt
 
Flight landing Project
Flight landing ProjectFlight landing Project
Flight landing Project
 

Recently uploaded

一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
Jio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdfJio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdf
inaya7568
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
ytypuem
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
soxrziqu
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
taqyea
 
Cell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docxCell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docx
vasanthatpuram
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Kaxil Naik
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
Márton Kodok
 
Building a Quantum Computer Neutral Atom.pdf
Building a Quantum Computer Neutral Atom.pdfBuilding a Quantum Computer Neutral Atom.pdf
Building a Quantum Computer Neutral Atom.pdf
cjimenez2581
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
aguty
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
eoxhsaa
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
Timothy Spann
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
bmucuha
 
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
lzdvtmy8
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
Vietnam Cotton & Spinning Association
 

Recently uploaded (20)

一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
Jio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdfJio cinema Retention & Engagement Strategy.pdf
Jio cinema Retention & Engagement Strategy.pdf
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
一比一原版(曼大毕业证书)曼尼托巴大学毕业证如何办理
 
University of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma TranscriptUniversity of New South Wales degree offer diploma Transcript
University of New South Wales degree offer diploma Transcript
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
 
Cell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docxCell The Unit of Life for NEET Multiple Choice Questions.docx
Cell The Unit of Life for NEET Multiple Choice Questions.docx
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
Orchestrating the Future: Navigating Today's Data Workflow Challenges with Ai...
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
 
Building a Quantum Computer Neutral Atom.pdf
Building a Quantum Computer Neutral Atom.pdfBuilding a Quantum Computer Neutral Atom.pdf
Building a Quantum Computer Neutral Atom.pdf
 
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
一比一原版澳洲西澳大学毕业证(uwa毕业证书)如何办理
 
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
一比一原版多伦多大学毕业证(UofT毕业证书)学历如何办理
 
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
06-12-2024-BudapestDataForum-BuildingReal-timePipelineswithFLaNK AIM
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
 
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
[VCOSA] Monthly Report - Cotton & Yarn Statistics March 2024
 

Applications of the DOW loop

  • 1. Applications of the DOW LoopApplications of the DOW Loop
  • 2. Table of Contents • Introduction • Structure of DOW Loop • Application 1: Cartesian Join • Application 2: Geometric Mean • Multiple DOW Loop • Application 3: Bivariate Regression • Conclusion
  • 3. Introduction • A simple data step concept first proposed by Ian Whitlock on the SAS – L list with Don Henderson. • Detail analysis by Paul Dorfman and Howard Schreier. • The term DOW (DO – Whitlock) loop was coined by Dorfman.
  • 4. Structure of the DOW Loop • The original DOW loop is a simple do loop with a set statement in the structure. Data ... ; <Stuff done before break-event> ; Do <Index Specs> Until ( Break-Event ) ; Set A ; <Stuff done for each record> ; End ; <Stuff done after break-event... > ; Run ;
  • 5. Application 1: Cartesian Join • Cartesian Join is one of the simple things that can be easily achieved in a single SQL statement. PROC SQL; CREATE TABLE DATA AS SELECT * FROM A,B; QUIT;
  • 6. Application 1: Cartesian Join • Cartesian Joins can also be done using a simple DOW loop. • Not as simple and as elegant as the SQL statement • Applicable to all versions of SAS DATA CART_JOIN; SET A; DO J = 1 TO COUNT; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 7. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 8. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 9. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 10. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 11. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 12. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 13. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 14. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 15. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 16. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 17. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 18. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 19. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 20. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 21. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 22. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 23. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 24. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 25. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 26. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 27. The engine A B C D 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 DATA CART_JOIN; SET A; DO J = 1 TO 4; SET B NOBS=COUNT POINT=J; OUTPUT; END; RUN;
  • 28. Application 2: Geometric Mean • Most of the mathematical and statistical functions in SAS are column based and deriving a calculation for just a single column can be very troublesome. • The DOW loop provides a simple solution to these problems. • We can use a DOW loop to loop through the observations and derive the answer.
  • 29. Application 2: Geometric Mean /*LOOP RUN*/ DATA _NULL_; /*SINGLE DO LOOP*/ DO UNTIL (EOF); SET HAVE END=EOF; BY CATEGORY; /*RESETING THE PREVIOUS VALUE*/ IF FIRST.CATEGORY THEN DO; TOTAL = 1; COUNT = 0; END; /*CALCULATING THE TOTAL SUM AND COUNTS VALUE*/ TOTAL = TOTAL*NUMBER; COUNT = SUM(COUNT,1); /*OUTPUTING THE RESULTS AND THE GEOMETRIC MEAN CALCULATION*/ IF LAST.CATEGORY THEN DO; /*CALCULATION FORMULA AS PER THE INSTRUCTION IN SAS HELP*/ GEOMEAN = TOTAL**(1/COUNT); /*OUTPUTING THE SOLUTION*/ PUT CATEGORY= GEOMEAN=; OUTPUT; END; END; RUN;
  • 30. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value
  • 31. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1
  • 32. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1
  • 33. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1
  • 34. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2
  • 35. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3
  • 36. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3
  • 37. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3 3
  • 38. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3 3 6
  • 39. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3 3 6
  • 40. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3 3 6 4
  • 41. DATA _NULL_; DO UNTIL (EOF); SET A END = EOF; COUNT = SUM(COUNT,1); VALUE = SUM(VALUE,A); END; RUN; The engine A B C D 1 2 3 4 2 2 3 4 3 2 3 4 4 2 3 4 Count Value 1 1 2 3 3 6 4 10
  • 42. Multiple DOW Loop • The double DOW loop structure was first proposed by Howard Scherier on the SAS – L as a variation of the original technique. • There have been several approaches which use multiple DOW loops to achieve various calculations which requires multiple iterations through the data.
  • 43. Application 3: Bivariate Regression • In order to calculate the parameters of the regression, we have to first calculate the mean of both the x and y variables. • After running through this, we will then use the mean to calculate the sum of square for both x-squares and xy which are essential for the regression parameter estimation.
  • 44. Application 3: Bivariate Regression /****************************************************************************** ------------------------------------------------------------------------------- DOW LOOP REGRESSION ------------------------------------------------------------------------------- THIS MACRO IS A SIMPLE DEMONSTRATION THE USE OF DOUBLE DOW LOOP TO COMPUTE THE SLOPE AND INTERCEPT OF A SIMPLE LINEAR REGRESSION MODEL. ------------------------------------------------------------------------------- INPUT DESCRIPTION ------------------------------------------------------------------------------- INPUT INPUT DATASET Y DEPEDENT VARIABLE X INDEPENDENT VARIABLE ------------------------------------------------------------------------------- *******************************************************************************/ %LET INPUT = HTWT; %LET Y = HEIGHT; %LET X = WEIGHT; /******************************************************************************/
  • 45. Application 3: Bivariate Regression /****************************************************************************** MAIN MACRO *******************************************************************************/ %MACRO DOW_REG(); /******************************************************************************/ /****************************************************************************** *******************************************************************************/ DATA _NULL_; /****************************************************************************** FIRST DOW LOOP FOR MEANS CALCULATION SUMMARIZATION *******************************************************************************/ DO I = 1 BY 1 UNTIL (EOF); SET &INPUT END=EOF; SUM_Y = SUM(SUM_Y,&Y); SUM_X = SUM(SUM_X,&X); COUNT = SUM(COUNT,1); END; /****************************************************************************** MEANS CALCULATION *******************************************************************************/ MEAN_Y = SUM_Y/COUNT; MEAN_X = SUM_X/COUNT;
  • 46. Application 3: Bivariate Regression /****************************************************************************** LOOP TO CALCULATE SUM OF SQUARES AND XY *******************************************************************************/ DO _N_ = 1 TO COUNT; SET &INPUT; XY = (&Y - MEAN_Y)*(&X - MEAN_X); XX = (&X - MEAN_X)**2; SUM_XY = SUM(SUM_XY,XY); SUM_XX = SUM(SUM_XX,XX); END; /****************************************************************************** CALCULATION OF SLOPES *******************************************************************************/ SLOPE = SUM_XY/SUM_XX; INTERCEPT = MEAN_Y - SLOPE*MEAN_X; PUT SLOPE = INTERCEPT = ; /****************************************************************************** *******************************************************************************/ RUN; %MEND; /****************************************************************************** MACRO CALLING *******************************************************************************/ %DOW_REG();
  • 47. Conclusion • One of the most versatile programming structures in SAS • Can be used on a variety of scenario to achieve the required results • Beside data manipulation, DOW loops are also useful for summarization of data, mathematical calculations and even model parameter estimations.

Editor's Notes

  1. The do loop in the middle is known as the DOW loop structure. The DOW loop basically separates the data step into three different steps. The first step is done to create some variables that need to be used for the DOW loop section. Typical statements in this area are RETAIN and ARRAY statements. The second part of the structure is the DOW loop itself. This part is the main engine of structure. It presents the user with a variety of options to create new variables, summarizing information and other nifty tricks to work with. This is also the section which can be very troublesome should the users do something wrong here. The last portion is a final calculation step which is useful for final summarization or calculations involving overall summarization. This step is occasionally being used for the subsequent DOW loops such as those in the Double DOW loop programming structure.
  2. You can distinctly see the structure of the DOW loop easily. The first set statement is the first portion of the DOW structure which basically reads in one dataset. The main part which is the DOW loop is the part that reads in the second dataset and setting each observations of the second dataset to the first dataset. Each combination is then outputted by the single output statement.
  3. In this particular DOW loop, only the main structure of the DOW is being used. The loop uses a EOF statement to identify the end of a loop and uses a by statement as in this case, it was a calculation of geometric mean for each sub category. At the end of each loop, a summarization process takes place and the geometric mean calculated accordingly.