In SAS, the PROC IMPORT procedure is used to import data from external files into SAS data sets. PROC IMPORT supports a variety of file types, including Excel, CSV, text, and database files. Some of the commonly used PROC IMPORT options include:
1. DATAFILE: specifies the name and location of the file to be imported.
2. OUT: specifies the name of the output data set.
3. DBMS: specifies the type of file to be imported (e.g. XLS, CSV, TXT, ACCESS).
4. REPLACE: specifies whether an existing output data set should be replaced.
5. GETNAMES: specifies whether variable names should be read from the file.
6. MIXED: specifies whether the file contains mixed data types.
7. RANGE: specifies a range of cells to import from an Excel file.
8. SHEET: specifies the name of the Excel worksheet to be imported.
9. GUESSINGROWS: specifies the number of rows to be scanned to determine the variable types.
10. USEDATE: specifies whether to convert dates to SAS date values.
These options can be used to customize the behavior of PROC IMPORT and to import data from a wide variety of file types. For example, the following code imports an Excel file named MYFILE.xlsx, reads data from the first worksheet, guesses variable types based on the first 20 rows, and creates a new data set called MYDATA:
proc import datafile=’C:\MYFILE.xlsx’ out=mydata dbms=xlsx replace;
sheet=’Sheet1′ guessingrows=20;
run;
This code reads the first 20 rows of data from the first worksheet in the Excel file, guesses the variable types, and writes the output data set to MYDATA.
What are the different proc export?
In SAS, the PROC EXPORT procedure is used to export SAS data sets to external files. PROC EXPORT supports a variety of file types, including Excel, CSV, text, and database files. Some of the commonly used PROC EXPORT options include:
1. DATA: specifies the name of the input SAS data set to be exported.
2. OUTFILE: specifies the name and location of the output file.
3. DBMS: specifies the type of file to be exported (e.g. XLS, CSV, TXT, ACCESS).
4. REPLACE: specifies whether an existing output file should be replaced.
5. SHEET: specifies the name of the Excel worksheet to be exported.
6. LABEL: specifies whether variable labels should be included in the output file.
7. PUTNAMES: specifies whether variable names should be included in the output file.
These options can be used to customize the behavior of PROC EXPORT and to export data to a wide variety of file types. For example, the following code exports a SAS data set called MYDATA to an Excel file named MYFILE.xlsx, creates a new worksheet named Sheet1, and includes variable labels:
proc export data=mydata outfile=’C:\MYFILE.xlsx’ dbms=xlsx replace;
sheet=’Sheet1′ label;
run;
This code exports the MYDATA data set to an Excel file named MYFILE.xlsx, creates a new worksheet named Sheet1, and includes variable labels in the output file.
Enroll for instructor led training free demo
Course Categories
SAS Tutorial For Beginners
- adtest
- test
- SAS Programming Global Options
- SAS Programming Fundamentals
- SAS Numeric Formats
- SAS Date Formats
- SAS Programming Macros
- SAS Programming SQL
- What are the different options in transpose?
- SAS Programming Graphs
- What are the different options in proc tabulet?
- What are the different options in proc report?
- What are the different options in proc freq?
- What are the different options in proc means?
- What are the different arrays in SAS?
- What are the different loops in SAS?
- What are the different options in conditional statements?
- What are the different options in merge?
- SAS Programming proc print & proc sort options?
- SAS Programming Functions
- SAS Programming proc import & Proc Export options?
- SAS Programming Data Set Options in SAS?
- SAS Programming proc format?
- SAS Programming Infile options
- SAS Programming input methods
- What are the Proc Contents in SAS?
- How to create SAS Libiray?
- How to create simple Program in SAS?
- SAS Software windows
- SAS Introduction