SlideShare a Scribd company logo
1 of 47
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

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.pdfannaielectronicsvill
 
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 codesrizrazariz
 
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 planAmol 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 codessrizrazariz
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1MANDHASAIGOUD1
 
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 CodySolutionVibeesh 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
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxvamsiyadav39
 
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 .docxMARRY7
 
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 PythonwinChad Cooper
 
Vlsi ii project presentation
Vlsi ii project presentationVlsi ii project presentation
Vlsi ii project presentationRedwan Islam
 
ECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comsantricksapiens71
 
Ecet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comEcet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comWilliamsTaylorzm
 
Ecet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comEcet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comStephenson033
 
ECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comsholingarjosh102
 

Similar to Applications of the DOW loop (20)

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
 
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
 
ECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.com
 
Ecet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comEcet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.com
 
Ecet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comEcet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.com
 
ECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.com
 
ERTS UNIT 3.ppt
ERTS UNIT 3.pptERTS UNIT 3.ppt
ERTS UNIT 3.ppt
 

Recently uploaded

Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGIThomas Poetter
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一F sss
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queensdataanalyticsqueen03
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfBoston Institute of Analytics
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxdolaknnilon
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsVICTOR MAESTRE RAMIREZ
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...ttt fff
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.natarajan8993
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 

Recently uploaded (20)

Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGILLMs, LMMs, their Improvement Suggestions and the Path towards AGI
LLMs, LMMs, their Improvement Suggestions and the Path towards AGI
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Top 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In QueensTop 5 Best Data Analytics Courses In Queens
Top 5 Best Data Analytics Courses In Queens
 
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdfPredicting Salary Using Data Science: A Comprehensive Analysis.pdf
Predicting Salary Using Data Science: A Comprehensive Analysis.pdf
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
IMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptxIMA MSN - Medical Students Network (2).pptx
IMA MSN - Medical Students Network (2).pptx
 
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制南十字星大学毕业证(SCU毕业证)#文凭成绩单#真实留信学历认证永久存档
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Advanced Machine Learning for Business Professionals
Advanced Machine Learning for Business ProfessionalsAdvanced Machine Learning for Business Professionals
Advanced Machine Learning for Business Professionals
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
毕业文凭制作#回国入职#diploma#degree美国加州州立大学北岭分校毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#de...
 
RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.RABBIT: A CLI tool for identifying bots based on their GitHub events.
RABBIT: A CLI tool for identifying bots based on their GitHub events.
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 

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.