EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials SAS Tutorial DO WHILE in SAS
Secondary Sidebar
SAS Tutorial
  • Basic
    • What is SAS
    • Advantages of SAS
    • Career in SAS
    • SAS Command
    • SAS Operators
    • SAS Export to CSV
    • Loops in SAS
    • DO WHILE in SAS
    • SAS System Interview Questions
    • SSAS Interview Questions
    • SAS Visual Analytics
    • SAS Join
    • SAS Length
    • SAS INTNX
    • SAS Congruence
    • SAS LAG Function
    • SAS boxplot
    • SAS INTCK
    • SAS Find
    • SAS Grid
    • SAS Triangle Calculator
    • SAS KEEP
    • SAS YEAR Function
    • SAS Format
    • SAS Libname
    • SAS Rename
    • SAS Retain
    • SAS Base
    • SAS JMP
    • SAS Array
    • SAS Round
    • SAS DO Loop
    • SAS Index
    • SAS Datalines
    • SAS Model
    • SAS Logistic Regression
    • SAS Numeric to Character
    • SAS Label
    • SAS ODS
    • SAS Upcase
    • SAS Numeric Formats
    • SAS Nodupkey

DO WHILE in SAS

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.

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.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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
Popular Course in this category
SAS Training (9 Courses, 10+ Projects)
  9 Online Courses |  10 Hands-on Projects |  123+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Data Visualization Training (15 Courses, 5+ Projects)4.9
Business Intelligence Training (12 Courses, 6+ Projects)4.8
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

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

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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*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?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more