0% found this document useful (0 votes)
2 views2 pages

Conditional Programming

Uploaded by

tanay rishu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Conditional Programming

Uploaded by

tanay rishu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q1.

Using the SASHELP data set FISH, create a new, temporary SAS data set
called Group_Fish that contains variables Species, Weight, and Height. Using IF-
THEN-ELSE logic, create a new variable called Group_Fish that places the fish into
weight as follows.
O to 100=1, 101-200=2, 201-500=3, 501-1000=4 and 1001 and greater-5
Use PROC_PRINT to list the first 10 observations from the data set Group_Fish
and show it in class.
Q2. Create a new temporary SAS data set called High_BP containing subjects
from SASHELP.Heart data set who have systolic blood pressure greater than 250
or diastolic blood pressure greater than 180. The new data set should only have
variables Diastolic, Systolic, and Status.
Use PROC_PRINT to list the contexts of High_BP.

Ans 1

/* Step 1: Create the temporary dataset Group_Fish with specified variables and
logic */
data Group_Fish;
set sashelp.fish; /* Access the SASHELP.FISH dataset */
/* Retain only the required variables */
keep Species Weight Height Group_Fish;
/* Use IF-THEN-ELSE logic to classify weights into groups */
if Weight <= 100 then Group_Fish = 1;
else if Weight <= 200 then Group_Fish = 2;
else if Weight <= 500 then Group_Fish = 3;
else if Weight <= 1000 then Group_Fish = 4;
else Group_Fish = 5;
run;

/* Step 2: Print the first 10 observations of Group_Fish dataset */


proc print data=Group_Fish(obs=10) noobs;
title "First 10 Observations from the Group_Fish Dataset";
run;
Ans 2

/* Step 1: Create a new dataset High_BP with the specified conditions */


data High_BP;
set sashelp.heart; /* Access the SASHELP.HEART dataset */
/* Retain only the required variables */
keep Diastolic Systolic Status;
/* Apply the filter for high blood pressure */
if Systolic > 250 or Diastolic > 180;
run;

/* Step 2: Print the contents of High_BP dataset */


proc print data=High_BP noobs;
title "Subjects with High Blood Pressure from SASHELP.Heart";
run;

You might also like