BookmarkSubscribeRSS Feed
kaushiklu
Calcite | Level 5

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 .

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

Hi,

  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:

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a002645704.htm

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.

cynthia

Ksharp
Super User

Add it into Cynthia ,The fourth method is NAMED input.

Ksharp

Cynthia_sas
SAS Super FREQ

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.

cynthia

DouglasMartin
Calcite | Level 5

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.

Howles
Quartz | Level 8

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.

Peter_C
Rhodochrosite | Level 12

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

peterC    

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 823 views
  • 0 likes
  • 6 in conversation