Help using Base SAS procedures

Reading a txt file into SAS?

Reply
Super Contributor
Posts: 338

Reading a txt file into SAS?

Hi Community,

  • I have a data set “data.txt” (“txt” is the extension name)
  • It has 37 variables and 1.3 million customers (records)
  • I just opened the data set, and it automatically opened in notepad.
  • The "Heading record" is found as a continuous string like below.

"Bank number","Start date","Branch number","Person name", “Balance", and so on…….

(note that names of some variables are having spaces)

  • Each record of descriptor portion is also found as a continuous string as follows, seperated by commas.

77,22/2/2011 0:00:00,6,"JOHN JOSEPH", and so on……

First of all, I need to run some descriptive statistics in SAS and get some feel about the data set.

I have given the following command to read the data set in SAS.

data test;

     infile 'H:\Model_Building\data.txt' firstobs=2 dlm='09'x dsd;

     input

Bank number Current date Branch number Short name Balance ........

;

Run;

My question

  1. Is this approach correct?
  2. Name of a single variable has two names (how to handle this?)

Help is highly appreciated.

Thank you

Mirisage

Frequent Contributor
Posts: 110

Reading a txt file into SAS?

Frequent Contributor
Posts: 110

Re: Reading a txt file into SAS?

Would you try like this

proc import datafile='H:\Model_Building\data.txt' dbms=dlm out=work.test replace;

delimiter=",";

getnames=yes;

guessingrows=500;

run;

Super Contributor
Posts: 338

Re: Reading a txt file into SAS?

Hi SASSHARP,

Thank you very much.

Mirisage

Ask a Question
Discussion stats
  • 3 replies
  • 272 views
  • 0 likes
  • 2 in conversation