10-27-2013 05:07 AM
I have a flat file of 1000 observations and 50 variables. I can able to directly extract this by proc import procedure but how can we assign formats to this data? Do we have any thing while importing can we assign length, data type, label? Can any one suggest me on this plz.
10-27-2013 08:58 AM
you can try to import the data using the data step instead of the proc import procedure, incase if you wish to control the formats, length etc., of the variables.
Something like below,
input variables name .............;
10-27-2013 10:01 AM
Immediately after running proc import press function key F4. That will give you the code that was run and you can modify all of the formats and informats as desired and then rerun the modified code.
10-27-2013 10:16 AM
I tried to import a sample data by proc import in sas 9.2 and after execution by default in the log it displayed the back end datastep it executed for proc import.
So probably for sas version less than 9.2 we need to use the function f4 to get the same.
10-27-2013 05:18 PM
Of Note: Don't expect the proc generated code to be optimal, well written code. IT WON'T BE! When you press F4 you will get the exact code that the proc submits, but the proc-generated code has numerous macro variables and checks that don't have to be there, and uses separate format and informat statements for every variable. Obviously, getting rid of the fluff and taking advantage of variable lists can make the code a lot easier to maintain.
10-28-2013 11:18 PM
so if i importing a file
proc import datafile='C:\Users\x\Desktop\SAS Files\test.xls' out=new replace;
and after running this code when i pres the F4 i get the same code as above
Can you please explaing this below ?
"The log displays the code that was run, but pressing function key f4 inserts that code into your editor."
10-29-2013 12:24 AM
Ah, this is the first time (that I know of at least) that you mentioned you were importing an Excel workbook. All of my suggestions were based on the (apparently wrong) assumption that you were importing a text or delimited file.
10-29-2013 02:01 PM
Tal: You really ought to start a new discussion rather than trying to piggyback onto an existing one.
However, while I don't think proc import lets you control formats and informats, the excel libname engine does. Take a look at http://books.google.ca/books?id=QOI_xTgWwgsC&pg=PA35&lpg=PA35&dq=import+excel+libname+engine+format+...
and, specifically, search that file for DBTYPE