Wednesday, March 2, 2011
Data import
For accessing data which is in the form of "Excel spreadsheet(*.xls)",the following
procedure can be used in SAS.
libname test C:\mysas\; /*Assigns a library named test on location C:\mysas\*/
proc import out=test.data1/*set data1 as the name for new data on "test" library*/
datafile="C:\..\data.xls" /*Location of the datafile to be imported*/
dbms=excel replace;
sheet="sheet1$"; /*specifies the sheetname to be read*/
getnames=yes; /*to get the variable names from the first row of data*/
mixed=no; /*to convert numeric values to characters in a mixed type column*/
scantext=yes; /*to use the largest text size in a column as sas variable length*/
usedate=yes; /*use DATE. format for a Date/Time column*/
scantime=yes; /*use TIME. format if only time values found in a column*/
run;
Similarly,for accessing a Tab Delimited(*.txt) file:
libname test C:\mysas\; /*Assigns a library namest test on location C:\mysas\ */
proc import out=test.data1 /*set data1 as the name for new data*/
datafile="C:\..\data.txt" /*Location of the datafile to be imported*/
dbms=tab replace;
getnames=yes; /*to get the variable names from the first row of data*/
datarow=2; /*to select the row on which data starts*/
run;
And for getting a Comma Seperated Values(*.csv)file:
libname test C:\mysas\; /*Assigns a library namest test on location C:\mysas\ */
proc import out=test.data1 /*set data1 as the name for new data*/
datafile="C:\..\data.csv" /*Location of the datafile to be imported*/
dbms=csv replace;
getnames=yes; /*to get the variable names from the first row of data*/
datarow=2; /*to select the row on which data starts*/
run;
Subscribe to:
Post Comments (Atom)
Please change the color of comments.....
ReplyDeleteimport export data Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our.
ReplyDelete