Friday 2 October 2015

SAS Assignment



 Using the SAS data set BloodPressure, produce a report showing Gender, Age, SBP,        and DBP. Order the report in Gender and Age order

Code

Output



Using the SAS data set College, report the mean GPA for the following categories of ClassRank: 0–50 = bottom half, 51–74 = 3rd quartile, and 75 to 100 = top quarter. Do this by creating an appropriate format. Do not use a DATA step


Code 




Output


Using the data set Blood, produce frequencies for the variable Chol (cholesterol). Use a format to group the frequencies into three groups: low to 200 (normal), 201 and higher (high), and missing. Run PROC FREQ twice, once using the MISSING option, and once without. Compare the percentages in both listings. 


Code


Output




Produce the following table. Note that the keyword ALL has been renamed Total, Gender is formatted, and ClassRank (a continuous numeric variable) has been formatted into two groups (0–70 and 71 and higher). 

Code


Output 




. Produce the following table. Note that the ALL column has been renamed Total.


 Code


Output




Saturday 19 September 2015

Basics of SAS



Basic programs of  SAS


Problem Statement

creating new data set using do statement

Code

Creating dataset



Program




Output 


Problem Statement

Q 2 )Create and print a data set with variables N and Log N, where Log N is the natural log
of N (the function is LOG). Use a DO loop to create a table showing values of N and
Log N for values of N going from 1 to 20.


Code



Output

Problem Statement

Q 3 )Repeat Problem , except have the range of N go from 5 to 100 by 5.

Code




Output


Poblem Statement

Q 4)  Use an iterative DO loop to plot the following equation:
y = 3*x2 � 5*x + 10
Use values of x from 0 to 10, with an increment of .10. Copy the GPLOT statements
from Problem 8 or use PROC PLOT to display the resulting equation.

Code





Output



Problem Statement 


Q 5 ) Use an iterative DO loop to plot the following equation:
Logit = log(p / (1 � p))
Use values of p from 0 to 1 (with a point at every .05). Using the following GPLOT
statements will produce a very nice plot. (If you do not have SAS/GRAPH
software, use PROC PLOT to plot your points).

Code




Output




Problem Statement 


Q 6 )Generate a table of integers and squares starting at 1 and ending when the square
value is greater than 100. Use either a DO UNTIL or DO WHILE statement to
accomplish this


Code




Output



Problem Statement 


Q 7),Using the SAS data set Hosp, create a temporary SAS data set called Monday 2002,
consisting of observations from Hosp where the admission date (Admit  Date) falls on
a Monday and the year is 2002. Include in this new data set a variable called Age,
computed as the person�s age as of the admission date, rounded to the nearest year.
creating hosp data set


Code


Output


Problem Statement 



Q 8),Print out the observations in the two data sets Inventory and New Products. Next,
create a new temporary SAS data set (Updated) containing all the observations in
Inventory followed by all the observations in New Products. Sort the resulting data
set and print out the observations.
6. Repeat Problem 5, except this time sort Inventory and New Products first (create two
temporary SAS data sets for the sorted observations). Next, create a new, temporary
SAS data set (Updated) by interleaving the two temporary, sorted SAS data sets.
Print out the result.*/
*Data set INVENTORY;


Code




Output 


Problem Statement



Q 9 Using the SAS data set Survey 1, create a new, temporary SAS data set (Survey   1)
where the values of the variables Ques 1�Ques 5 are reversed as follows: 1 .. 5; 2
.. 4; 3 .. 3; 4 .. 2; 5 .. 1.
Note: Ques 1�Ques 5 are character variables*/


Code




Output



Problem Statement

Q 10  Using the Gym data set, create a new, temporary SAS data set (Percent) that contains
all the variables found in Gym plus a new variable (call it Cost Percent) that
represents the Cost as a percentage of the average cost for all subjects. Use PROC
MEANS to create a SAS data set containing the mean cost (see Program 10-7 to see
how to do this). Round this value to the nearest percent.*/;
*Data set GYM;


Code




Output