Help using Base SAS procedures

proc import

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 75
Accepted Solution

proc import

I've got the following file I'm trying to import

namq_aux_lp     07.07.2014

namq_aux_ulc      08.07.2014

namq_aux_gph      07.07.2014

prc_hicp_cann       17.07.2014

namq_nace10_k      02.07.2014

sei_bsco_m      10.06.2014

ei_bsin_m_r2      26.06.2014

lassei_bsbu_m_r2      26.06.2014

assei_bsrt_m_r2      26.06.2014

ei_bssi_m_r2      26.06.2014

ei_bsse_m_r2      26.06.2014

ei_bsci_m_r2      26.06.2014

sts_trtu_m      17.07.2014

I've used the following proc import's

proc import out=lesdates datafile="C:\work\studies\project\data\calend\bigfilev2.txt" dbms=tab REPLACE; getnames=no; run;

proc import out=lesdates datafile="C:\travail\etudes\projetpib\donnees\calend\bigfilev2.txt" dbms=tab REPLACE; delimiter='09'x; getnames=no; run;

But each time, instead of having 2 variables, I'm ending with one variable taking the 2 columns

         var1

------------------------------

namq_aux_lp      07.07.2014

namq_aux_ulc      08.07.2014

namq_aux_gph      07.07.2014

prc_hicp_cann      17.07.2014

namq_nace10_k      02.07.2014

sei_bsco_m      10.06.2014

ei_bsin_m_r2      26.06.2014

lassei_bsbu_m_r2    26.06.2014

assei_bsrt_m_r2     26.06.2014

ei_bssi_m_r2      26.06.2014

ei_bsse_m_r2      26.06.2014

ei_bsci_m_r2      26.06.2014

sts_trtu_m          17.07.2014

What am I doing wrong???

PS: I can edit the text file but I would like to do the import without touching anything.


Accepted Solutions
Solution
‎07-22-2014 10:44 AM
Super User
Super User
Posts: 7,988

Re: proc import

Is the delimiter matching what is between the two text's?  Open with a hex editor and check it, it maybe that that gap is spaces or something.  I would personally go with a specified delimiter, e.g. pipe/comma etc. so its clear, I really don't like non-printable characters.

You could try the datastep version:

data want;

     attrib some_text format=$200. adate informat=ddmmyy10. format=ddyymm10.;

     infile "...\yourfile.txt" dlm='09'x;

     input...

run;

View solution in original post


All Replies
Solution
‎07-22-2014 10:44 AM
Super User
Super User
Posts: 7,988

Re: proc import

Is the delimiter matching what is between the two text's?  Open with a hex editor and check it, it maybe that that gap is spaces or something.  I would personally go with a specified delimiter, e.g. pipe/comma etc. so its clear, I really don't like non-printable characters.

You could try the datastep version:

data want;

     attrib some_text format=$200. adate informat=ddmmyy10. format=ddyymm10.;

     infile "...\yourfile.txt" dlm='09'x;

     input...

run;

Frequent Contributor
Posts: 75

Re: proc import

Thanks RW9. It is working great.

Super User
Posts: 11,343

Re: proc import

Your DLM=TAB says it expects the data to be tab delimited. Are you sure the data has TABS?

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 218 views
  • 0 likes
  • 3 in conversation