EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials SAS Tutorial DO WHILE in SAS
 

DO WHILE in SAS

Updated March 6, 2023

DO WHILE in SAS

 

 

Introduction to DO WHILE in SAS

SAS is a statistical analysis system that gives a complete solution for business analysis such as analyses, reporting, data mining, and predictive modeling with the help of powerful visualizations and interactive dashboards. It is mainly used for medical purpose analysis. For programming, it has the two steps data step and procedure step. In data, we have to explain the data we are giving and the procedure step it helps for the execution.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

In SAS there are three basic loops that are DO LOOP, DO UNTIL and DO WHILE Here we are introducing DO WHILE LOOP. It is a control flow statement. In SAS statement repeatedly executes as per the condition until the while condition becomes false.

Syntax:

DO WHILE (condition); Statements;
END
;

In syntax, we have to give conditions inside the brackets. In the second line, we have to give the statements for the execution then we have to give END command for closing the loop.

Flow Chart:

flow chart
In this flowchart clearly know that it stops the execution when the while condition becomes false For details please check below with the working and examples.

Working

All of you know that the DO WHILE LOOP helps for the repeat calculation at multiple numbers of times as per the condition. In SAS normally have to stop iteration when the certain is met. It has two options normally DO UNTIL and DO WHILE loop. In DO WHILE LOOP it stops iteration when the while condition fails. The condition must be checked in each iteration once it fails it stops the execution. In coding is very useful for repetition cases and sequence generation cases. Easily generate sequence as per the condition. For easy knowing while we taking the financial part of our life most of the people had loan or EMI. So, we have to calculate repayment such as how many times we have to repay it can easily calculate with DO WHILE loop. We need amount details only. Here we are explaining just simple program only.

Program #1

Data new; i=1;
do while(i<=5);output; i=i+1;
end;
proc print new; run;

Explanation:

In this program, we just give the name of the data as new. Here we are going to print up to 1 to 5. In the data step after naming the data we just take I as a variable and gave the value as 1 then the DO WHILE LOOP condition I <=5. After it iterates as per the given condition. It will generate up to 5 after that while loop fails Suddenly it stops the execution.

Output:

DO WHILE in SAS

Program #2

data Work* investment do while(capital<50000); capital+capital *,10; year+1;
Output; End;
Proc print Work*investment Run;

Explanation:

In this program, I just give the work* investment. Because the program is to calculate the amount of capital as per year. Normally I just give a name as per the program because it is very useful to keep the file after that I give the condition on DO WHILE LOOP in that the capital less than 50000 after that give the statements for calculation and for the year and I give output statement and procedural steps. It will generate the capital by year until the while condition fails.

Output:

DO WHILE in SAS 1

Conclusion

Normally all type of programming languages has the DO WHILE LOOP.SAS is a Business Analytical software also. In SAS very easy to write and run the program. Because lower case and upper case characters are allowed .it has two steps data step and procedure step. In DO WHILE LOOP iterates the statements as per the given condition until while condition becomes wrong. It has a very important role in our daily life. Because if you programmer it helped for the repetition of calculation and if you are the normal person it used to calculate some essential financial calculations such as EMI calculations how many months we have repay the amount like that. So, we think a very important portion it helps some logical calculations as per our needs.

Recommended Articles

This is a guide to DO WHILE in SAS. Here we discuss the Introduction, syntax, flow chart, How to work? with program. You may also have a look at the following articles to learn more –

  1. SASS @for
  2. SASS Map
  3. SASS @extend
  4. SASS Nesting

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW