07-03-2011 10:56 AM
Hi , I am using(mainframe) for last 8 months only . In one interview I was asked that there are 4 methods to read a file in SAS program . Could you please provide me the four methods .
07-03-2011 03:44 PM
Without knowing more specifically about what type of file (because, the method you would use to read an Oracle file, for example, differs from the method you would use to read a raw data file). However, if you look at the documentation, I believe you will find the answer to that question:
There are mainly three ways to read raw data files into a SAS program to create a SAS dataset: LIST input, COLUMN input and FORMATTED input and then, since you can "mix" types of input, some people consider MIXED input (where you use LIST and COLUMN or COLUMN and FORMATTED or ...) to be a 4th method.
07-04-2011 12:56 AM
True....I haven't used it in so long, I forget it's even there. So did the doc site I listed. So I guess that's 5 overall -- if you count NAMED -and- the ability to mix the input types.
07-04-2011 08:53 AM
That question can be interpreted more than one way. The others have mentioned the various forms of an INPUT statement, which may very well be what was intended. However, looking at the question from a different point of view, four methods to read a file that I can think of would be INFILE, PROC IMPORT, LIBNAME (using a non-default engine) and %INCLUDE.
07-05-2011 09:10 PM
Yes, it does depend on interpretation. I can think of only (1) the INPUT statement and (2) the FREAD function. Others (PROC IMPORT, External File Interface, Enterprise Guide) arguably don't count because they simply generate code for #1.
07-06-2011 07:49 AM
Are we to allow a "file" to include a database such as a sql server "file"?
Then a SAS program might "read" that "file" with the ODBC libname engine.
A file might be a sas table.
A SAS program reads such a file with many different methods, that vary not just within the capabilities of a DATA step but also over the many different PROC steps and sometimes varying with the platform on which SAS is running.
DATA step INPUT statements offer a large variety of methods (more than 4). FREAD provides a different approach to reading a file in a DATA step (or even in the macro language environment).
Perhaps PROC SOAP should be considered too, as its online doc starts "PROC SOAP reads XML input from a file" .....
that interview question is beginning to sound a bit vague... which is OK for an interview as it opens up a conversation, at least to clarify and expand on that question .....
The interviewer might want to hear more that a quick list of 4