SAS PROGRAMMING HANDOUT #2 THE DATA STEP SAS programs generally consist of a series of "DATA STEP"s and "PROC"s. The "DATA STEP" are used to enter and manipulate data. The "PROC"s are used to perform preprogrammed statistical procedures. DATA STEP: The easiest way to enter data into a data step is as follows: DATA ONE; *Here ONE is the name of the data set. (no funny symbols); INPUT X A $; *This data set has 2 variables. X is numeric and A is character; X2=X*X; *New variables can be defined after the INPUT statement.; CARDS; *COMMENTS go here; 21 ABC 23.2 A .3 XYZ PROC PRINT DATA=ONE; *USE CURSOR TO HIGHLITE PROGRAM AND SUBMIT; RUN; Data can also be read from an ASCI file on your diskette. Save the above three lines of data as a file on A: (or C:) called ONE.DAT Click on FILE, SAVE AS, A:(or C:), *.dat type, then give filename DATA TWO; INFILE 'A:\ONE.DAT'; INPUT X A $; PROC PRINT DATA=TWO; RUN; Data can also be saved as a "permanent SAS data set". LIBNAME BOB 'A:\'; DATA BOB.THREE; SET TWO; RUN; This will save the data set on A; as THREE.SAS7BDAT In version 6 the extension was *.SD2 DATA FOUR; SET BOB.THREE; PROC PRINT DATA=FOUR; RUN; This will create a new data set using THREE.SAS7BDAT Data can also be written from a SAS data set to an ASCI file DATA FIVE; SET FOUR; FILE 'A:\SIX.DAT'; PUT @1 X @10 A; RUN; There are several other ways to enter data into the SAS system 1) INFILE 'A:\COMMA.DAT' DELIMITER=','; This will read a comma delimited data set. 2) Click on FILE, IMPORT This will let you use EXCEL files etc You should first create a LIBNAME You can also export files to different formats. 3) PROC INSIGHT allows a spreadsheet form of data entry.