A fairly common practice is to separate adjacent data values with a comma (,).These comma-delimited data can be easily read by a SAS program as long as you tell the program what to expect.In this case you do so through the use of an INFILE statement as follows(output would be identical to the previous output, with the exception of the title):
As you will see later in this chapter,an INFILE statement is usually used to indicate that the raw data are stored in,and are being read from,an external file.The location,or source,or file specification of the external data is named in the INFILE statement, and a number of options that control how the data are read can also be included.
By using the reserved filename DATALINES,you can apply some of these options to instream data.(Note:the older term CARDS still works even if you use a DATALINES statement to begin your data.)In the present example, the option DLM=','tells the program to use commas rather than spaces as data delimiters.You may choose any data delimiter you wish with this option.You can even choose multiple characters such as DLM='XX' for your delimiter.
An improvement to the DLM= option was made available in Release 6.07 of the SAS System.A new option, DSD,allows you to treat two consecutive deli miters as containing a missing value.In addition,you can read a text string that contains the delimiter if it is contained in quotes. Further,quoted text strings can also be read.
In both cases,the quotes surrounding the text string are not included in the stored value.If the DSD option is used without the DLM= option,the SAS System assumes that you are using commas as your delimiter.The following program demonstrates the use of the DSD option:
Output from Example - Reading Data Values Separated by Commas or Other Delimiters]OBS X Y TEXT
Notice that the SAS System treats the consecutive commas as containing a missing value,omits the quotes from the data values,and allows you to include a comma in a text string.The DSD option is probably most useful in reading files produced by spreadsheet and database programs that produce DIF (data interchange format)files.
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.