SlideShare une entreprise Scribd logo
1  sur  7
Venkata Maguluri
Types of conditional statements in SAS:
1) WHERE
  a) where “condition”;                                        = where
2) IF
  a) if “condition” then “statement”;                          = if -- then
  b) if “condition” then “statement”; else “statement”;        = if – then – else
  c) if “condition” then “statement”; else if “statement”;     = if – then – else -- if
3) DO
  a) if “condition” then do; “statement”; end;                 = if – then – do
  b) do while “condition”; “statement”; end;                   = do while
  c) do until “condition” ; “statement”; end;                  = do until
  d) do “var” = “start” to “end”; “statement”; end;            = do loop
  e) do “var” = “start” to “end” by “inc”; “statement”; end;   = do loop
  f) do over “array”; “statement”; end;                        = do loop
WHERE conditional statement in SAS:
1) WHERE
    a) where “condition”;                                           = where
    It is used to select observations that meet a particular condition in a dataset
    The conditions in where statement can be numeric or character expression
    You can use only one where statement in a data step or in a proc step
Examples:-
/* Selecting observations in a data step */
data dm1;
  set derived.dm;
  where . < 18 <= age <= 55 and gender=“M”;
run;
/* Selecting observations for processing in a proc step */
proc means data=derived.dm;
  where . < age <= 55 and gender=“F”;
run;

http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000202951.htm
IF conditional statement in SAS:
2) IF
    a) if “condition” then “statement”;                          = if -- then
    b) if “condition” then “statement”; else “statement”;        = if – then – else
    c) if “condition” then “statement”; else if “statement”;     = if – then – else – if
    Processes only those observations that meet the condition
    The conditions in if statement can be numeric or character expression
    You can use more than one if statement in a data step
Example:-
data dm1;
 set dm;
 if citycode=5564 then city=„Mumbai‟                           = if -- then
 if . < age <= 25 then young=„Yes‟;                            = if – then – else
 else young=„No‟;
 if 18 <= age <= 25 then agegrp=‟18 – 25 years‟;               = if – then – else – if
 else if 26 <= age <= 35 then agegrp=„26 – 35 years‟;
 else if 36 <= age <= 45 then agegrp=„36 – 45 years‟;
 else agegrp=„> 46 years‟;
run;
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000201978.htm
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000202239.htm
DO conditional statement in SAS:
3) DO
  a) if “condition” then do; “statement”; end;                 = if – then – do
  b) do while “condition”; “statement”; end;                   = do while
  c) do until “condition” ; “statement”; end;                  = do until
  d) do “var” = “start” to “end”; “statement”; end;            = do loop
  e) do “var” = “start” to “end” by “inc”; “statement”; end;   = do loop
  f) do over “array”; “statement”; end;                        = do loop
DO conditional statement in SAS:
1) DO
   The do statement is valid in a data step
   It specifies a group of statements to be executed as a unit
   Every do loop has a corresponding end statement
   The statements between the do and end statements are called a DO group
   You can nest do statements within do groups
   A simple do statement is often used within if – then – else statements to designate a group
    of statements to be executed depending on whether the if condition is true or false
    do until statement executes statements in a do loop repetitively until a condition is
    true, checking the condition after each iteration of the do loop
    do while statement executes statements in a do loop repetitively while a condition is
    true, checking the condition before each iteration of the do loop
   The do until statement evaluates the condition at the bottom of the loop
   The do while statement evaluates the condition at the top of the loop
   do over loop used to perform the operations in the do loop over ALL elements in the array
   Within a single do loop multiple arrays can be referenced and operations on different
    arrays can be performed
   if “Any Questions” then “Drop me a mail”
     else if “NO Questions” then “Comment below”


   if “Any Questions” then
        do “Ask and Drop me a mail”
        end
 else if “NO Questions” then “Leave your comment”   

Contenu connexe

Tendances

CDISC SDTM Domain Presentation
CDISC SDTM Domain PresentationCDISC SDTM Domain Presentation
CDISC SDTM Domain PresentationAnkur Sharma
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1venkatam
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sasAjay Ohri
 
A Step-By-Step Introduction to SAS Report Procedure
A Step-By-Step Introduction to SAS Report ProcedureA Step-By-Step Introduction to SAS Report Procedure
A Step-By-Step Introduction to SAS Report ProcedureYesAnalytics
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SASguest2160992
 
Report procedure
Report procedureReport procedure
Report procedureMaanasaS
 
Base SAS Full Sample Paper
Base SAS Full Sample Paper Base SAS Full Sample Paper
Base SAS Full Sample Paper Jimmy Rana
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.Ravi Mandal, MBA
 
Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Mark Tabladillo
 
A Roadmap for SAS Programmers to Clinical Statistical Programming
A Roadmap for SAS Programmers to Clinical Statistical ProgrammingA Roadmap for SAS Programmers to Clinical Statistical Programming
A Roadmap for SAS Programmers to Clinical Statistical ProgrammingMohammad Majharul Alam
 
Presentation on CDISC- SDTM guidelines.
Presentation on CDISC- SDTM guidelines.Presentation on CDISC- SDTM guidelines.
Presentation on CDISC- SDTM guidelines.Khushbu Shah
 
SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connectguest2160992
 

Tendances (20)

CDISC SDTM Domain Presentation
CDISC SDTM Domain PresentationCDISC SDTM Domain Presentation
CDISC SDTM Domain Presentation
 
SAS Macros
SAS MacrosSAS Macros
SAS Macros
 
SAS Internal Training
SAS Internal TrainingSAS Internal Training
SAS Internal Training
 
SAS Functions
SAS FunctionsSAS Functions
SAS Functions
 
SAS Macros part 1
SAS Macros part 1SAS Macros part 1
SAS Macros part 1
 
Introduction to sas
Introduction to sasIntroduction to sas
Introduction to sas
 
A Step-By-Step Introduction to SAS Report Procedure
A Step-By-Step Introduction to SAS Report ProcedureA Step-By-Step Introduction to SAS Report Procedure
A Step-By-Step Introduction to SAS Report Procedure
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQL
 
Data Match Merging in SAS
Data Match Merging in SASData Match Merging in SAS
Data Match Merging in SAS
 
Report procedure
Report procedureReport procedure
Report procedure
 
Sas
SasSas
Sas
 
Base SAS Full Sample Paper
Base SAS Full Sample Paper Base SAS Full Sample Paper
Base SAS Full Sample Paper
 
Understanding sas data step processing.
Understanding sas data step processing.Understanding sas data step processing.
Understanding sas data step processing.
 
Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3Proc SQL in SAS Enterprise Guide 4.3
Proc SQL in SAS Enterprise Guide 4.3
 
Sas Plots Graphs
Sas Plots GraphsSas Plots Graphs
Sas Plots Graphs
 
A Roadmap for SAS Programmers to Clinical Statistical Programming
A Roadmap for SAS Programmers to Clinical Statistical ProgrammingA Roadmap for SAS Programmers to Clinical Statistical Programming
A Roadmap for SAS Programmers to Clinical Statistical Programming
 
Basics of SAS
Basics of SASBasics of SAS
Basics of SAS
 
Proc report
Proc reportProc report
Proc report
 
Presentation on CDISC- SDTM guidelines.
Presentation on CDISC- SDTM guidelines.Presentation on CDISC- SDTM guidelines.
Presentation on CDISC- SDTM guidelines.
 
SAS Access / SAS Connect
SAS Access / SAS ConnectSAS Access / SAS Connect
SAS Access / SAS Connect
 

En vedette

Varun Singh Cv 2008 10 Marketing With Work Ex.2003
Varun Singh Cv 2008 10 Marketing With Work Ex.2003Varun Singh Cv 2008 10 Marketing With Work Ex.2003
Varun Singh Cv 2008 10 Marketing With Work Ex.2003vrnsingh6
 
Sass Why for the CSS Guy
Sass Why for the CSS GuySass Why for the CSS Guy
Sass Why for the CSS GuyBeau Smith
 
Learn SAS Programming
Learn SAS ProgrammingLearn SAS Programming
Learn SAS ProgrammingSASTechies
 
Base SAS Exam Questions
Base SAS Exam QuestionsBase SAS Exam Questions
Base SAS Exam Questionsguestc45097
 

En vedette (6)

Varun Singh Cv 2008 10 Marketing With Work Ex.2003
Varun Singh Cv 2008 10 Marketing With Work Ex.2003Varun Singh Cv 2008 10 Marketing With Work Ex.2003
Varun Singh Cv 2008 10 Marketing With Work Ex.2003
 
Sas
SasSas
Sas
 
Sass Why for the CSS Guy
Sass Why for the CSS GuySass Why for the CSS Guy
Sass Why for the CSS Guy
 
Learn SAS Programming
Learn SAS ProgrammingLearn SAS Programming
Learn SAS Programming
 
Base SAS Exam Questions
Base SAS Exam QuestionsBase SAS Exam Questions
Base SAS Exam Questions
 
SAS basics Step by step learning
SAS basics Step by step learningSAS basics Step by step learning
SAS basics Step by step learning
 

Similaire à Conditional statements in sas

Similaire à Conditional statements in sas (20)

control statement
control statement control statement
control statement
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
SPL 7 | Conditional Statements in C
SPL 7 | Conditional Statements in CSPL 7 | Conditional Statements in C
SPL 7 | Conditional Statements in C
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structures
 
programming c language.
programming c language. programming c language.
programming c language.
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
Decision Controls in C++ Programming Lecture
Decision Controls in C++ Programming LectureDecision Controls in C++ Programming Lecture
Decision Controls in C++ Programming Lecture
 
M C6java5
M C6java5M C6java5
M C6java5
 
Decision Structures
Decision StructuresDecision Structures
Decision Structures
 
C Programming - Decision making, Looping
C  Programming - Decision making, LoopingC  Programming - Decision making, Looping
C Programming - Decision making, Looping
 
Decision Making and Branching in C
Decision Making and Branching  in CDecision Making and Branching  in C
Decision Making and Branching in C
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Conditional Statements.pptx
Conditional Statements.pptxConditional Statements.pptx
Conditional Statements.pptx
 
L3 control
L3 controlL3 control
L3 control
 
Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)Fcp chapter 2 upto_if_else (2)
Fcp chapter 2 upto_if_else (2)
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
 
Java chapter 3
Java chapter 3Java chapter 3
Java chapter 3
 

Dernier

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Conditional statements in sas

  • 2. Types of conditional statements in SAS: 1) WHERE a) where “condition”; = where 2) IF a) if “condition” then “statement”; = if -- then b) if “condition” then “statement”; else “statement”; = if – then – else c) if “condition” then “statement”; else if “statement”; = if – then – else -- if 3) DO a) if “condition” then do; “statement”; end; = if – then – do b) do while “condition”; “statement”; end; = do while c) do until “condition” ; “statement”; end; = do until d) do “var” = “start” to “end”; “statement”; end; = do loop e) do “var” = “start” to “end” by “inc”; “statement”; end; = do loop f) do over “array”; “statement”; end; = do loop
  • 3. WHERE conditional statement in SAS: 1) WHERE a) where “condition”; = where  It is used to select observations that meet a particular condition in a dataset  The conditions in where statement can be numeric or character expression  You can use only one where statement in a data step or in a proc step Examples:- /* Selecting observations in a data step */ data dm1; set derived.dm; where . < 18 <= age <= 55 and gender=“M”; run; /* Selecting observations for processing in a proc step */ proc means data=derived.dm; where . < age <= 55 and gender=“F”; run; http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000202951.htm
  • 4. IF conditional statement in SAS: 2) IF a) if “condition” then “statement”; = if -- then b) if “condition” then “statement”; else “statement”; = if – then – else c) if “condition” then “statement”; else if “statement”; = if – then – else – if  Processes only those observations that meet the condition  The conditions in if statement can be numeric or character expression  You can use more than one if statement in a data step Example:- data dm1; set dm; if citycode=5564 then city=„Mumbai‟ = if -- then if . < age <= 25 then young=„Yes‟; = if – then – else else young=„No‟; if 18 <= age <= 25 then agegrp=‟18 – 25 years‟; = if – then – else – if else if 26 <= age <= 35 then agegrp=„26 – 35 years‟; else if 36 <= age <= 45 then agegrp=„36 – 45 years‟; else agegrp=„> 46 years‟; run; http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000201978.htm http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000202239.htm
  • 5. DO conditional statement in SAS: 3) DO a) if “condition” then do; “statement”; end; = if – then – do b) do while “condition”; “statement”; end; = do while c) do until “condition” ; “statement”; end; = do until d) do “var” = “start” to “end”; “statement”; end; = do loop e) do “var” = “start” to “end” by “inc”; “statement”; end; = do loop f) do over “array”; “statement”; end; = do loop
  • 6. DO conditional statement in SAS: 1) DO  The do statement is valid in a data step  It specifies a group of statements to be executed as a unit  Every do loop has a corresponding end statement  The statements between the do and end statements are called a DO group  You can nest do statements within do groups  A simple do statement is often used within if – then – else statements to designate a group of statements to be executed depending on whether the if condition is true or false  do until statement executes statements in a do loop repetitively until a condition is true, checking the condition after each iteration of the do loop  do while statement executes statements in a do loop repetitively while a condition is true, checking the condition before each iteration of the do loop  The do until statement evaluates the condition at the bottom of the loop  The do while statement evaluates the condition at the top of the loop  do over loop used to perform the operations in the do loop over ALL elements in the array  Within a single do loop multiple arrays can be referenced and operations on different arrays can be performed
  • 7.  if “Any Questions” then “Drop me a mail” else if “NO Questions” then “Comment below”   if “Any Questions” then do “Ask and Drop me a mail” end else if “NO Questions” then “Leave your comment” 