Posts

Showing posts with the label Excel files

How to Import Excel files into SAS

Reading from Excel Spreadsheets: Microsoft Excel spreadsheets can be read from SAS in several ways. Two of these will be demonstrated here. First, PROC IMPORT allows direct access to Excel files through SAS/Access to PC File Formats or access to Comma-Separated (CSV) files through Base SAS. The second method uses the Excel LIBNAME engine. PROC IMPORT The IMPORT procedure reads from external sources and creates a SAS data set. Two sources are Excel spreadsheets and CSV files. A particular SAS/Access product may be required for certain sources, however. In our example, SAS/Access to PC File Formats is required to read an Excel file, but a CSV file can be accessed with Base SAS. General Syntax for PROC IMPORT: PROC IMPORT DATAFILE=" c:\sas\ego.csv " OUT=jeeshim.egov DBMS=CSV REPLACE; For Excel you use the DATAFILE =”filename” option to specify the Excel file to be read. (The TABLE=”tablename” option would be applicable if you were reading from a database such as Microso...

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...