Posts

Showing posts with the label DLM

How to create a comma separated file (.csv) of a SAS dataset?

IN SAS programming, we often require outputting the dataset in different formats like EXCEL and CSV etc and here are the five different ways to export the SAS dataset into .csv file. Example: data new ; infile datalines dsd dlm=' ' missover; input a b c d; datalines; 3 5 1 1 4 1 . . 5 8 3 2 6 0 4 4 ; run ; By putting MISSOVER in the infile statement we are telling SAS to do not look for the data in the next lane if it runs out of the data, instead keep missing values for any remaining variables. DSD and DLM options should be included always in the infile statement, if we include the dlm=’ ‘ in the infile statement then SAS will put one digit for each variable even though we haven’t assigned any length to variable. DSD option will tell SAS to consider a missing value if 2 delimiters are present side by side in any observation. When we ran the above program in SAS, we create a SAS dataset name ‘ NEW’ in the work directory and if we want to create a ...

Options in SAS' INFILE Statement

Options in SAS' INFILE Statement There are a number of options available for the INFILE statement. Below you will find discussion of the following options: DLM='character', DSD, MISSOVER, and FIRSTOBS=value. DLM='character' When I prepare a data file for list input to SAS, I use a blank space as the delimiter. The delimiter is the character which must appear between the score for one variable and that for the next variable. One can, however, choose to use a delimiter other than a blank space. For example, the comma is a commonly used delimiter. If you are going to use a delimiter other than a blank space, you must tell SAS what the delimiter is. Here is an example of a couple of data lines in a comma delimited file: 4,2,8010,2,4,2,4,4,2,2,2,2,2,2,4,4,2,4,2,2,CDFR,22,900,5,4,1 4,2,8011,1,2,3,1,3,4,4,4,1,2,2,4,2,3,4,3,1,psychology,24,360,4,3,1 Here is the INFILE statement which identified the delimiter as being a comma: infile 'd:\Research-Misc\Hale\Hale.csv' ...