Posts

Showing posts with the label Firstobs=

Getting the Data into SAS

GETTING DATA INTO SAS direct link: http://www.biostat.ucla.edu/course/m403b/M403B2005_2DataInput.pdf 1. Importing data from other sources • Use DBMS Copy, STAT Transfer, or some other software that performs similar functions. • Use SAS/ACCESS or the SAS Import feature in Windows. • Use PROC IMPORTS to read certain types of data files. • Create a raw data (ASCII) file then use INPUT and INFILE statements to read the raw data file in SAS programs. 2. Creating SAS data sets with raw (ASCII) data files • Data are placed within the SAS program directly after the DATALINES or CARDS statement. Use INPUT statement to read the data. *** Read data within SAS program as SAS data file ***; DATA survey; INPUT Q1Major Q2Degree Q3SASpast Q4ProjData Q5SASexprn Q6SASfutur; DATALINES; 2 1 1 1 2 8 2 2 0 0 0 7 2 1 0 0 1 4 2 1 0 1 0 8 more raw data lines ; RUN ; • In the above example, – Spaces (or other types of delimiters) are required between data values – Missing values must be specified (blank sp...

Options in SAS' INFILE Statement

Options in SAS' INFILE Statement There are a number of options available for the INFILE statement. Below you will find discussion of the following options: DLM='character', DSD, MISSOVER, and FIRSTOBS=value. DLM='character' When I prepare a data file for list input to SAS, I use a blank space as the delimiter. The delimiter is the character which must appear between the score for one variable and that for the next variable. One can, however, choose to use a delimiter other than a blank space. For example, the comma is a commonly used delimiter. If you are going to use a delimiter other than a blank space, you must tell SAS what the delimiter is. Here is an example of a couple of data lines in a comma delimited file: 4,2,8010,2,4,2,4,4,2,2,2,2,2,2,4,4,2,4,2,2,CDFR,22,900,5,4,1 4,2,8011,1,2,3,1,3,4,4,4,1,2,2,4,2,3,4,3,1,psychology,24,360,4,3,1 Here is the INFILE statement which identified the delimiter as being a comma: infile 'd:\Research-Misc\Hale\Hale.csv' ...