<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Importing several .txt files into one file i SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22304#M4873</link>
    <description>Hi Oleg and thanks for the input. It dosen't work tough.&lt;BR /&gt;
&lt;BR /&gt;
Im working on getting this code to work:&lt;BR /&gt;
&lt;BR /&gt;
*******************************************************&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe 'dir I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt /b'; &lt;BR /&gt;
data file_list; &lt;BR /&gt;
  length fname $25; &lt;BR /&gt;
infile indata truncover;  /* infile statement for file names */&lt;BR /&gt;
input fname $25.;  /* read the file names from the directory */&lt;BR /&gt;
call symput ('num_files',_n_); /* store the record number in a macro variable */&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro fileread; &lt;BR /&gt;
%do j=1 %to &amp;amp;num_files; &lt;BR /&gt;
data _null_; &lt;BR /&gt;
  set file_list; &lt;BR /&gt;
  if _n_=&amp;amp;j;  &lt;BR /&gt;
  call symput ('filein',fname); &lt;BR /&gt;
run; &lt;BR /&gt;
data var_names; &lt;BR /&gt;
  length x1-x60 $50; &lt;BR /&gt;
  infile "I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\&amp;amp;filein" obs=1 missover; &lt;BR /&gt;
  input (x1-x16) ($) ; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro varnames; &lt;BR /&gt;
%do i=1 %to 60; &lt;BR /&gt;
%global v&amp;amp;i; &lt;BR /&gt;
data _null_; &lt;BR /&gt;
  set var_names; &lt;BR /&gt;
  call symput("v&amp;amp;i",trim(x&amp;amp;i)); &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%mend varnames; &lt;BR /&gt;
%varnames; &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp; &lt;BR /&gt;
  infile "I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\&amp;amp;filein" firstobs=2 missover; &lt;BR /&gt;
  input (&amp;amp;v1 &amp;amp;v2 &amp;amp;v3 &amp;amp;v4 &amp;amp;v5 &amp;amp;v6 &amp;amp;v7 &amp;amp;v8 &amp;amp;v9 &amp;amp;v10 &amp;amp;v11 &amp;amp;v12 &amp;amp;v13 &amp;amp;v14 &amp;amp;v15 &amp;amp;v16 &amp;amp;v17 &amp;amp;v18&lt;BR /&gt;
&amp;amp;v19 &amp;amp;v20 &amp;amp;v21 &amp;amp;v22 &amp;amp;v23 &amp;amp;v24 &amp;amp;v25 &amp;amp;v26 &amp;amp;v27 &amp;amp;v28 &amp;amp;v29 &amp;amp;v30 &amp;amp;v31 &amp;amp;v32 &amp;amp;v33 &amp;amp;v34 &amp;amp;v35 &amp;amp;v36&lt;BR /&gt;
&amp;amp;v37 &amp;amp;v38 &amp;amp;v39 &amp;amp;v40 &amp;amp;v41 &amp;amp;v42 &amp;amp;v43 &amp;amp;v44 &amp;amp;v45 &amp;amp;v46 &amp;amp;v47 &amp;amp;v48 &amp;amp;v49 &amp;amp;v50 &amp;amp;v51 &amp;amp;v52 &amp;amp;v53 &amp;amp;v54&lt;BR /&gt;
&amp;amp;v55 &amp;amp;v56 &amp;amp;v57 &amp;amp;v58 &amp;amp;v59 &amp;amp;v60)($);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* assemble the individual files */ &lt;BR /&gt;
%if &amp;amp;j=1 %then %do; &lt;BR /&gt;
  data data_all; &lt;BR /&gt;
    set temp; &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%else %do; &lt;BR /&gt;
data data_all; &lt;BR /&gt;
    set data_all &lt;BR /&gt;
        temp; &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%end;  /* end of do-loop with index j */&lt;BR /&gt;
%mend fileread; &lt;BR /&gt;
%fileread; &lt;BR /&gt;
&lt;BR /&gt;
**************************************************&lt;BR /&gt;
&lt;BR /&gt;
It gives me some output, but it screws up in the second row, because its text and not numeric.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas?</description>
    <pubDate>Fri, 04 Mar 2011 13:29:10 GMT</pubDate>
    <dc:creator>TMorville</dc:creator>
    <dc:date>2011-03-04T13:29:10Z</dc:date>
    <item>
      <title>Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22302#M4871</link>
      <description>Hi. I have a problem that i can't seem to google myself out of. I've searched the forums, but without luck.&lt;BR /&gt;
&lt;BR /&gt;
I have a folder with a bunch of txt files called:&lt;BR /&gt;
&lt;BR /&gt;
wea-abo_02-03-2011.txt&lt;BR /&gt;
wea-abo_05-02-2011.txt&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
and so on.&lt;BR /&gt;
&lt;BR /&gt;
The variables are seperated by a single tab. They are always the same, and have the same names. One would think that i could use a infile statement, but i cant make it work!&lt;BR /&gt;
&lt;BR /&gt;
What i would like to do, is to import all of the .txt files into one big SAS file. IF possible, i would like SAS only to include, the first row only of the first workbook. This is the variable names, and its only nessesary for me to have them once. &lt;BR /&gt;
&lt;BR /&gt;
There are 58 variables, and each textfile is approx 50000 rows long. There are some text variables, and some numerical. I also have variables with 8 empty rows in the beginning.&lt;BR /&gt;
&lt;BR /&gt;
Any help or ideas would be appriciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!

Message was edited by: TMorville</description>
      <pubDate>Fri, 04 Mar 2011 11:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22302#M4871</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-04T11:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22303#M4872</link>
      <description>Hello.&lt;BR /&gt;
 Try this macro. It works on Windows. Edit some marked lines of code.&lt;BR /&gt;
&lt;BR /&gt;
 [pre]&lt;BR /&gt;
  %macro cfin10(input=d:\dep\input\2009, out=obordop2009);&lt;BR /&gt;
&lt;BR /&gt;
  /* read files in directory INPUT */&lt;BR /&gt;
&lt;BR /&gt;
  %let dir=%str(dir %")&amp;amp;input.%str(\%" /A-D/B/ON);&lt;BR /&gt;
&lt;BR /&gt;
  data &amp;amp;out ;&lt;BR /&gt;
  length  filevar $256. command $256. ;&lt;BR /&gt;
  command = symget('dir');&lt;BR /&gt;
  infile dummy0 pipe filevar=command truncover;&lt;BR /&gt;
  input myfiles $100.;&lt;BR /&gt;
  fname=quote(upcase(cats("&amp;amp;input",'\',myfiles)));&lt;BR /&gt;
&lt;BR /&gt;
  /* Edit below line of code - delimiter and firstobs */&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
  infile dummy1 firstobs=2 dlm=';' ls=32000 truncover dsd filevar=fname end=eof;&lt;BR /&gt;
&lt;BR /&gt;
  /* edit below line of code according to your data structure (fields) */&lt;BR /&gt;
&lt;BR /&gt;
  informat account $20. ss_naim $100. var1-var5 $1. ss_ostd 17. ss_ostc 17. ost_ccy 17. country $50. iso $3. client $100.&lt;BR /&gt;
           k_client $12. client_t $1. inn $char12. reg $char30. isin $char20. cb $char30.;&lt;BR /&gt;
  do while(not eof);&lt;BR /&gt;
&lt;BR /&gt;
  /* edit below line of code according to your data structure (fields) */&lt;BR /&gt;
&lt;BR /&gt;
  input account  ss_naim  var1-var5  ss_ostd  ss_ostc ost_ccy country  iso  client&lt;BR /&gt;
           k_client client_t  inn  reg isin  cb ;&lt;BR /&gt;
  end;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
  %mend cfin10;&lt;BR /&gt;
[/pre]

Message was edited by: Oleg_L</description>
      <pubDate>Fri, 04 Mar 2011 13:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22303#M4872</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-04T13:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22304#M4873</link>
      <description>Hi Oleg and thanks for the input. It dosen't work tough.&lt;BR /&gt;
&lt;BR /&gt;
Im working on getting this code to work:&lt;BR /&gt;
&lt;BR /&gt;
*******************************************************&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe 'dir I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt /b'; &lt;BR /&gt;
data file_list; &lt;BR /&gt;
  length fname $25; &lt;BR /&gt;
infile indata truncover;  /* infile statement for file names */&lt;BR /&gt;
input fname $25.;  /* read the file names from the directory */&lt;BR /&gt;
call symput ('num_files',_n_); /* store the record number in a macro variable */&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro fileread; &lt;BR /&gt;
%do j=1 %to &amp;amp;num_files; &lt;BR /&gt;
data _null_; &lt;BR /&gt;
  set file_list; &lt;BR /&gt;
  if _n_=&amp;amp;j;  &lt;BR /&gt;
  call symput ('filein',fname); &lt;BR /&gt;
run; &lt;BR /&gt;
data var_names; &lt;BR /&gt;
  length x1-x60 $50; &lt;BR /&gt;
  infile "I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\&amp;amp;filein" obs=1 missover; &lt;BR /&gt;
  input (x1-x16) ($) ; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro varnames; &lt;BR /&gt;
%do i=1 %to 60; &lt;BR /&gt;
%global v&amp;amp;i; &lt;BR /&gt;
data _null_; &lt;BR /&gt;
  set var_names; &lt;BR /&gt;
  call symput("v&amp;amp;i",trim(x&amp;amp;i)); &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%mend varnames; &lt;BR /&gt;
%varnames; &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp; &lt;BR /&gt;
  infile "I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\&amp;amp;filein" firstobs=2 missover; &lt;BR /&gt;
  input (&amp;amp;v1 &amp;amp;v2 &amp;amp;v3 &amp;amp;v4 &amp;amp;v5 &amp;amp;v6 &amp;amp;v7 &amp;amp;v8 &amp;amp;v9 &amp;amp;v10 &amp;amp;v11 &amp;amp;v12 &amp;amp;v13 &amp;amp;v14 &amp;amp;v15 &amp;amp;v16 &amp;amp;v17 &amp;amp;v18&lt;BR /&gt;
&amp;amp;v19 &amp;amp;v20 &amp;amp;v21 &amp;amp;v22 &amp;amp;v23 &amp;amp;v24 &amp;amp;v25 &amp;amp;v26 &amp;amp;v27 &amp;amp;v28 &amp;amp;v29 &amp;amp;v30 &amp;amp;v31 &amp;amp;v32 &amp;amp;v33 &amp;amp;v34 &amp;amp;v35 &amp;amp;v36&lt;BR /&gt;
&amp;amp;v37 &amp;amp;v38 &amp;amp;v39 &amp;amp;v40 &amp;amp;v41 &amp;amp;v42 &amp;amp;v43 &amp;amp;v44 &amp;amp;v45 &amp;amp;v46 &amp;amp;v47 &amp;amp;v48 &amp;amp;v49 &amp;amp;v50 &amp;amp;v51 &amp;amp;v52 &amp;amp;v53 &amp;amp;v54&lt;BR /&gt;
&amp;amp;v55 &amp;amp;v56 &amp;amp;v57 &amp;amp;v58 &amp;amp;v59 &amp;amp;v60)($);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* assemble the individual files */ &lt;BR /&gt;
%if &amp;amp;j=1 %then %do; &lt;BR /&gt;
  data data_all; &lt;BR /&gt;
    set temp; &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%else %do; &lt;BR /&gt;
data data_all; &lt;BR /&gt;
    set data_all &lt;BR /&gt;
        temp; &lt;BR /&gt;
run; &lt;BR /&gt;
%end; &lt;BR /&gt;
%end;  /* end of do-loop with index j */&lt;BR /&gt;
%mend fileread; &lt;BR /&gt;
%fileread; &lt;BR /&gt;
&lt;BR /&gt;
**************************************************&lt;BR /&gt;
&lt;BR /&gt;
It gives me some output, but it screws up in the second row, because its text and not numeric.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas?</description>
      <pubDate>Fri, 04 Mar 2011 13:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22304#M4873</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-04T13:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22305#M4874</link>
      <description>I can suggest you another way. See code below.&lt;BR /&gt;
I don't know your data structure. You did not provide the data here.&lt;BR /&gt;
You should edit "dlm=", "firstobs=", path to your files and "informat" and "input" according to the information in your text files.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
  data test ;&lt;BR /&gt;
  length filename $256.;&lt;BR /&gt;
  infile 'd:\mbm\2009\D20091106\input\*.txt' firstobs=3  dlm=';' ls=32000 truncover dsd eov=eov filename=filename;&lt;BR /&gt;
  informat account $20. ss_naim $100. var1-var5 $1. ss_ostd 17. ss_ostc 17. ost_ccy 17. country $50. iso $3. client $100.&lt;BR /&gt;
           k_client $12. client_t $1. inn $char12. reg $char30. isin $char20. cb $char30.;&lt;BR /&gt;
&lt;BR /&gt;
  input @;&lt;BR /&gt;
  if eov then do ;       &lt;BR /&gt;
      input /; &lt;BR /&gt;
    eov = 0 ; &lt;BR /&gt;
   end;&lt;BR /&gt;
&lt;BR /&gt;
  input account  ss_naim  var1-var5  ss_ostd  ss_ostc ost_ccy country  iso  client&lt;BR /&gt;
           k_client client_t  inn  reg isin  cb ;&lt;BR /&gt;
  file=filename;&lt;BR /&gt;
  run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 04 Mar 2011 14:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22305#M4874</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-04T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22306#M4875</link>
      <description>Hi again Oleg.&lt;BR /&gt;
&lt;BR /&gt;
The problem with your code is the non-flexible $variable lenghts.&lt;BR /&gt;
&lt;BR /&gt;
B/c i have names, adresses and many different categories and lenghts for my variables, it wont work.&lt;BR /&gt;
&lt;BR /&gt;
Here is a modified sample of my data with 20 rows:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://dl.dropbox.com/u/1321324/Work/sample.txt" target="_blank"&gt;http://dl.dropbox.com/u/1321324/Work/sample.txt&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Thanks!

Message was edited by: TMorville</description>
      <pubDate>Fri, 04 Mar 2011 14:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22306#M4875</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-04T14:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22307#M4876</link>
      <description>Try this code. You may want to edit variables informat.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
  %macro cfin10(input=d:\dep\input\2009, out=obordop2009);&lt;BR /&gt;
  /* read files in directory INPUT */&lt;BR /&gt;
  %let dir=%str(dir %")&amp;amp;input.%str(\%" /A-D/B/ON);&lt;BR /&gt;
  data &amp;amp;out (compress=yes drop=filevar);&lt;BR /&gt;
  length  filevar $256. command $256. fname $256.;&lt;BR /&gt;
&lt;BR /&gt;
  command = symget('dir');&lt;BR /&gt;
  infile dummy0 pipe filevar=command truncover;&lt;BR /&gt;
  input myfiles $100.;&lt;BR /&gt;
  fname=quote(upcase(cats("&amp;amp;input",'\',myfiles)));&lt;BR /&gt;
  infile dummy1 firstobs=2 dlm='09'x ls=32000 truncover dsd filevar=fname end=eof ;&lt;BR /&gt;
&lt;BR /&gt;
  informat&lt;BR /&gt;
&lt;BR /&gt;
ship_to_party                    $10.&lt;BR /&gt;
publication                      $5.&lt;BR /&gt;
edition                          $2.&lt;BR /&gt;
oplagskat                        $10.&lt;BR /&gt;
subscr_valid_from                ddmmyy10.&lt;BR /&gt;
bill_freq                        $10.&lt;BR /&gt;
pmethod                          $10.&lt;BR /&gt;
r_code                           $10.&lt;BR /&gt;
ordernr                          $9.&lt;BR /&gt;
fremtidig_aktiv                  $10.&lt;BR /&gt;
fornavn                          $50.&lt;BR /&gt;
efternavn                        $70.&lt;BR /&gt;
vej                              $70.&lt;BR /&gt;
husnr                            $10.&lt;BR /&gt;
husnr_suppl                      $5.&lt;BR /&gt;
etage                            $1.&lt;BR /&gt;
side                             $10.&lt;BR /&gt;
postnr                           17.&lt;BR /&gt;
by                               $50.&lt;BR /&gt;
land                             $2.&lt;BR /&gt;
tlf                              17.&lt;BR /&gt;
bp_kat                           $1.&lt;BR /&gt;
orgnavn1                         $50.&lt;BR /&gt;
orgnavn2                         $50.&lt;BR /&gt;
orgnavn3                         $50.&lt;BR /&gt;
orgnavn4                         $10.&lt;BR /&gt;
EMail                            $50.&lt;BR /&gt;
Marketing_campaign               $10.&lt;BR /&gt;
ship_robinson                    $10.&lt;BR /&gt;
sold_to_party                    $10.&lt;BR /&gt;
sold_fornavn                     $50.&lt;BR /&gt;
sold_efternavn                   $50.&lt;BR /&gt;
sold_vej                         $50.&lt;BR /&gt;
sold_husnr                       17.&lt;BR /&gt;
sold_husnr_suppl                 $1.&lt;BR /&gt;
sold_etage                       $1.&lt;BR /&gt;
sold_side                        $1.&lt;BR /&gt;
sold_postnr                      17.&lt;BR /&gt;
sold_by                          $50.&lt;BR /&gt;
sold_land                        $2.&lt;BR /&gt;
sold_tlf                         17.&lt;BR /&gt;
sold_bp_kat                      $1.&lt;BR /&gt;
sold_orgnavn1                    $50.&lt;BR /&gt;
sold_orgnavn2                    $50.&lt;BR /&gt;
sold_orgnavn3                    $50.&lt;BR /&gt;
sold_postbox                     $50.&lt;BR /&gt;
sold_email                       $50.&lt;BR /&gt;
sold_robinson                    $50.&lt;BR /&gt;
samme                            $2.&lt;BR /&gt;
tom_variabel2                    $10.&lt;BR /&gt;
del_end                          $10.&lt;BR /&gt;
endreason                        $10.&lt;BR /&gt;
matriculationdate                $10.&lt;BR /&gt;
suspension_from                  $10.&lt;BR /&gt;
suspension_to                    $10.&lt;BR /&gt;
Suspension_reason                $10.&lt;BR /&gt;
Delivery_type                    $1.&lt;BR /&gt;
pricegroup                       $10.&lt;BR /&gt;
  ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
  do while(not eof);&lt;BR /&gt;
  input&lt;BR /&gt;
ship_to_party&lt;BR /&gt;
publication&lt;BR /&gt;
edition&lt;BR /&gt;
oplagskat&lt;BR /&gt;
subscr_valid_from&lt;BR /&gt;
bill_freq&lt;BR /&gt;
pmethod&lt;BR /&gt;
r_code&lt;BR /&gt;
ordernr&lt;BR /&gt;
fremtidig_aktiv&lt;BR /&gt;
fornavn&lt;BR /&gt;
efternavn&lt;BR /&gt;
vej&lt;BR /&gt;
husnr&lt;BR /&gt;
husnr_suppl&lt;BR /&gt;
etage&lt;BR /&gt;
side&lt;BR /&gt;
postnr&lt;BR /&gt;
by&lt;BR /&gt;
land&lt;BR /&gt;
tlf&lt;BR /&gt;
bp_kat&lt;BR /&gt;
orgnavn1&lt;BR /&gt;
orgnavn2&lt;BR /&gt;
orgnavn3&lt;BR /&gt;
orgnavn4&lt;BR /&gt;
EMail&lt;BR /&gt;
Marketing_campaign&lt;BR /&gt;
ship_robinson&lt;BR /&gt;
sold_to_party&lt;BR /&gt;
sold_fornavn&lt;BR /&gt;
sold_efternavn&lt;BR /&gt;
sold_vej&lt;BR /&gt;
sold_husnr&lt;BR /&gt;
sold_husnr_suppl&lt;BR /&gt;
sold_etage&lt;BR /&gt;
sold_side&lt;BR /&gt;
sold_postnr&lt;BR /&gt;
sold_by&lt;BR /&gt;
sold_land&lt;BR /&gt;
sold_tlf&lt;BR /&gt;
sold_bp_kat&lt;BR /&gt;
sold_orgnavn1&lt;BR /&gt;
sold_orgnavn2&lt;BR /&gt;
sold_orgnavn3&lt;BR /&gt;
sold_postbox&lt;BR /&gt;
sold_email&lt;BR /&gt;
sold_robinson&lt;BR /&gt;
samme&lt;BR /&gt;
tom_variabel2&lt;BR /&gt;
del_end&lt;BR /&gt;
endreason&lt;BR /&gt;
matriculationdate&lt;BR /&gt;
suspension_from&lt;BR /&gt;
suspension_to&lt;BR /&gt;
Suspension_reason&lt;BR /&gt;
Delivery_type&lt;BR /&gt;
pricegroup&lt;BR /&gt;
 ;&lt;BR /&gt;
 if not missing(ship_to_party) then output; &lt;BR /&gt;
  end;&lt;BR /&gt;
  run;&lt;BR /&gt;
&lt;BR /&gt;
  %mend cfin10;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%cfin10(input=d:\work\morv, out=tmorville);&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Oleg_L&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Oleg_L

Message was edited by: Oleg_L</description>
      <pubDate>Fri, 04 Mar 2011 15:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22307#M4876</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-04T15:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22308#M4877</link>
      <description>Hi. Maybe you need another option.&lt;BR /&gt;
[pre]&lt;BR /&gt;
infile "I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\&amp;amp;filein" firstobs=2 missover &lt;B&gt;expandtabs &lt;/B&gt;; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Or Alternative way is to use SAS default proc import which will avoid to make some mistake.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 07 Mar 2011 02:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22308#M4877</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-07T02:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22309#M4878</link>
      <description>when you know the column structure, IMPORT is seldom the best alternative&lt;BR /&gt;
Here, it can be very simple&lt;BR /&gt;
I created 5 copys of the text named DK1 to DK5.txt which are read with the 6 lines&lt;BR /&gt;
data ;&lt;BR /&gt;
 infile 'C:\Users\Peter Crawford\Documents\My SAS Files\dk*.txt' dsd dlm='09'x lrecl=10000 firstobs=2 eov=eov  truncover ;&lt;BR /&gt;
 input @ ;&lt;BR /&gt;
  if eov then do;  eov=0 ; delete ; end ;&lt;BR /&gt;
  else input (col1 - col33 )(:$30);&lt;BR /&gt;
run;&lt;BR /&gt;
The EOV flag is set to 1 when the input rolls over from one file to the next (and needs to be reset)./&lt;BR /&gt;
You adapt the data step for column names, lengths and date or other special (in)formats and if you keep the column definitions in order, the main input statement becomes even simpler[pre] else input ship_to_party -- pricegroup  ;[/pre]That structure is &lt;BR /&gt;
 input first_column -- last_column ;&lt;BR /&gt;
which will include all intermediate columns too. The will be read with their default informats.</description>
      <pubDate>Mon, 07 Mar 2011 15:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22309#M4878</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-07T15:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22310#M4879</link>
      <description>Hi.&lt;BR /&gt;
Peter. I know data step have more control to input data and more flexible.&lt;BR /&gt;
I think OP maybe miss the option dlm='09'x or expandtabs to generate the unwanted &lt;BR /&gt;
result.&lt;BR /&gt;
&lt;BR /&gt;
For you wildchar about infile statement, there is one disadvantage that you are hard to control which txt file to input firstly,that mean the order of data maybe you do not want.&lt;BR /&gt;
I think OP use infile dummy filevar=  is good enough. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 08 Mar 2011 01:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22310#M4879</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-08T01:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22311#M4880</link>
      <description>K&lt;BR /&gt;
expandtabs might help less (as it removes what appear to be reliable delimiters.);&lt;BR /&gt;
I saw no request to control input file order (When that is important, I normally seek to add the name of each file that is being loaded, with the data using FILENAME=);&lt;BR /&gt;
I have found more overheads in the FILEVAR= method than in the * wildchar method.&lt;BR /&gt;
 &lt;BR /&gt;
Hence my recommendation&lt;BR /&gt;
 &lt;BR /&gt;
P</description>
      <pubDate>Tue, 08 Mar 2011 18:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22311#M4880</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-08T18:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22312#M4881</link>
      <description>Dear Peter:&lt;BR /&gt;
 I do not know what to say. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I think OP 's problem maybe miss dlm='09'x option.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 09 Mar 2011 04:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22312#M4881</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-09T04:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22313#M4882</link>
      <description>Hi guys and thanks for the replys! It warms my SAS-padawan heart do learn stuff like this. &lt;BR /&gt;
&lt;BR /&gt;
I like Peter.C solution, as it seems most flexible. But i can't really get it to work. My code looks like this now:&lt;BR /&gt;
&lt;BR /&gt;
This is my errorlog:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
347  data ;&lt;BR /&gt;
348  infile 'I:\WEA\WEA-Marketing\Analyse\Data\P10\Dump\Txt\we*.txt' dsd dlm='09'x lrecl=10000&lt;BR /&gt;
348! firstobs=2 eov=eov truncover ;&lt;BR /&gt;
349  input ship_to_party -- pricegroup; ;&lt;BR /&gt;
ERROR: Variable ship_to_party cannot be found on the list of previously defined variables.&lt;BR /&gt;
350  if eov then do; eov=0 ; delete ; end ;&lt;BR /&gt;
351  run;&lt;BR /&gt;
&lt;BR /&gt;
Theres a chance i've misunderstood this sentance about inputting (in)formats?&lt;BR /&gt;
&lt;BR /&gt;
PS: While im at it, i've gotten Oleg method to work (Thanks!) - and that causes me a new problem. If i have a variable thats a string of text like "wea-abo_29-01-2011.txt" can SAS recognize the date in the text, and translate it into a sas date like 29JAN2011?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!

Message was edited by: TMorville</description>
      <pubDate>Wed, 09 Mar 2011 09:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22313#M4882</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-09T09:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22314#M4883</link>
      <description>-&amp;gt; PS: While im at it, i've gotten Oleg method to work (Thanks!) - and that causes me a new problem. If i have a variable thats a string of text like "wea-abo_29-01-2011.txt" can SAS recognize the date in the text, and translate it into a sas date like 29JAN2011?&lt;BR /&gt;
&lt;BR /&gt;
Add before the line " if not missing(ship_to_party) then output;"&lt;BR /&gt;
next code:&lt;BR /&gt;
date=input(substr(left(myfiles),9,10),ddmmyy10.);&lt;BR /&gt;
&lt;BR /&gt;
Oleg.</description>
      <pubDate>Wed, 09 Mar 2011 11:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22314#M4883</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-09T11:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22315#M4884</link>
      <description>Hi again Oleg. &lt;BR /&gt;
&lt;BR /&gt;
I have another problem with your code. No matter how many lines there are in the .txt document. Your code only imports 37508? Any ideas?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: TMorville

Message was edited by: TMorville</description>
      <pubDate>Wed, 09 Mar 2011 11:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22315#M4884</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-09T11:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22316#M4885</link>
      <description>Try to replace " if not missing(ship_to_party) then output;" with "output;"&lt;BR /&gt;
or another guess is to add option "ignoredoseof" to the infile statement.&lt;BR /&gt;
But I'm not sure.&lt;BR /&gt;
&lt;BR /&gt;
infile dummy1 firstobs=2 dlm='09'x ls=32000 truncover dsd filevar=fname end=eof  &lt;B&gt; ignoredoseof &lt;/B&gt;;</description>
      <pubDate>Wed, 09 Mar 2011 11:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22316#M4885</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-09T11:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Importing several .txt files into one file i SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22317#M4886</link>
      <description>ignoreduseof worked like a charm! Thanks!</description>
      <pubDate>Wed, 09 Mar 2011 12:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Importing-several-txt-files-into-one-file-i-SAS/m-p/22317#M4886</guid>
      <dc:creator>TMorville</dc:creator>
      <dc:date>2011-03-09T12:05:37Z</dc:date>
    </item>
  </channel>
</rss>

