SAS Blog 1 Part 3: Working with simple datasets


Lets cover one more question



  1. Write a program, using datalines, to load a permanent SAS data set called “patient” from data below:

ID
Gender
DoB
Height
Weight
001
M
21/10/1946
171
70.1
002
F
26/5/1950
163
55.5
003
M
11/5/1981
180
81.4
004
M
4/7/1983
174
56.3
005
F
25/12/2009
80
25.1
 

 
                   Use appropriate format for the variables.

    1. Run PROC CONTENTS on this data set
    2. Use SAS Studio to investigate the properties of this data set
    3. Run PROC PRINT on the data set you created

Code:
libname test "C:\Users\Elcot\Desktop\Term1\SAS Folders";
data test.patient;
input id gender$ DOB ddmmyy10. Height Weight;
datalines;
001 M 21/10/1946 171 70.1
002 F 26/5/1950 163 55.5
003 M 11/5/1981 180 81.4
004 M 04/7/1983 174 56.3
005 F 25/12/2009 80 25.1
;
run;
proc print data = test.patient;
format DOB ddmmyy10.;
run;
Explanation: Please follow part 1 and part 2 for in detail explanation of each line. Here we are using format of date as ddmmyy10. This is an inbuilt format for the dates to be output and would help you in creating the format as you observe in the question for the output


1)We can use the format option both in proc and data step statements
Other date types are:
date9.
2) Don't forget to end the format with a period
3) Other kinds are Dollar11.2 among many other

In case of any feedback please let me know as it would help in improvising the blog for further benefit
 

Comments

  1. 1. datalines do not need to end with a "run;" statement. just one ";" is fine.

    2. Put comment and title statement in your code

    3. In the context of the blog, "Learning" may be better than "Explanation"

    ReplyDelete

Post a Comment

Popular posts from this blog

Kabaddi Match: Lets meet at the arena!! Aa jao Dam Dikhane!!!

Text Analytics Using R - Part A: Extraction of reviews of galaxy s4 product reviews in flipkart

Replace your Social Media with the New Age Social Media: Fitness with Motivation