<?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: Multiple file import with leading zeros in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115206#M31853</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a very convenient way(variables list ) to make them all be character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;filename DIRLIST "c:\data\client\folder\Raw Data\*.txt" ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dirlist ;&lt;/P&gt;&lt;P&gt;infile dirlist lrecl=200 truncover;&lt;/P&gt;&lt;P&gt;input var1-var2000 : $200.;&lt;/P&gt;&lt;P&gt;...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Jul 2012 05:33:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-07-23T05:33:29Z</dc:date>
    <item>
      <title>Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115203#M31850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to import multiple (20+) comma delimited text files (.txt files not .csv) of varying lengths and number of variables. A "memberkey" column links all these files together. However, this variable has leading zeros, what's worse is that the member keys vary in length. For example there are two ids 000123 and 00123 which when imported are both 123 when that is clearly not the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written/modified a macro I found on the sas website to import all these files as they are in a common directory. This works great apart from the leading zero issue. I can't use an infile data step as I don't know all the field names and don't want to have to open up these files (too many of them).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My question is can I force proc import to somehow make all fields called "memberkey" text instead of numeric?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here is my macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename DIRLIST pipe 'dir "\data\client\folder\Raw Data\*.txt" ';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dirlist ;&lt;/P&gt;&lt;P&gt;infile dirlist lrecl=200 truncover;&lt;/P&gt;&lt;P&gt;input line $200.;&lt;/P&gt;&lt;P&gt;if find(line,".txt") = 0 then delete;&lt;/P&gt;&lt;P&gt;length file_name $ 200;&lt;/P&gt;&lt;P&gt;file_name="\data\client\folder\Raw Data\"||scan(line,-1," ");&lt;/P&gt;&lt;P&gt;keep file_name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set dirlist end=end;&lt;/P&gt;&lt;P&gt;count+1;&lt;/P&gt;&lt;P&gt;call symput('read'||left(count),left(trim(file_name)));&lt;/P&gt;&lt;P&gt;call symput('dset'||left(count),substr(file_name, 76, length(file_name) - 79));&lt;/P&gt;&lt;P&gt;if end then call symput('max',count);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options mprint symbolgen;&lt;/P&gt;&lt;P&gt;%macro readin;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;max;&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE="&amp;amp;&amp;amp;read&amp;amp;i"&lt;/P&gt;&lt;P&gt;OUT=data.&amp;amp;&amp;amp;dset&amp;amp;iv&lt;/P&gt;&lt;P&gt;DBMS=DLM&lt;/P&gt;&lt;P&gt;REPLACE;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;DELIMITER=",";&lt;/P&gt;&lt;P&gt;GUESSINGROWS=10000;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend readin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%readin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 03:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115203#M31850</guid>
      <dc:creator>dom_oh</dc:creator>
      <dc:date>2012-07-23T03:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115204#M31851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My guess is the PROC IMPORT is treating the the offending column as numeric and is dropping the leading zeroes as a consequence.&lt;BR /&gt;I did a test myself with this program:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;import&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;= test&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;datafile&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;"c:\test_data.txt"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;REPLACE&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;GETNAMES&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=YES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;DELIMITER&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;","&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then I looked in the log and found this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;/**********************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; PRODUCT:&amp;nbsp;&amp;nbsp; SAS&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; VERSION:&amp;nbsp;&amp;nbsp; 9.3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; CREATOR:&amp;nbsp;&amp;nbsp; External File Interface&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; DATE:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23JUL12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; DESC:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generated SAS Datastep Code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*&amp;nbsp;&amp;nbsp; TEMPLATE SOURCE:&amp;nbsp; (None Specified.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;***********************************************************************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data WORK.TEST&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile 'c:\test_data.txt' delimiter = ',' MISSOVER DSD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;lrecl=32767 firstobs=2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;informat ID best32. ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; informat _Text_var $14. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;format ID best12. ;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format _Text_var $14. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _Text_var $&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _ERROR_ then call symputx('_EFIERR_',1);&amp;nbsp; /* set ERROR detection macro variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note the highlighted INFORMAT and FORMAT statements showing the ID is being read as a number.&lt;/P&gt;&lt;P&gt;I suggest you look at your LOG as it will have similar code. You can copy this code back into your program by using your mouse with the ALT key pressed to avoid the LOG row numbers to highlight the required statements then do a CTRL C and CTRL V to get it into your program. You can then edit the highlighted statements to be read and displayed as character (don't forget to put a $ sign after the ID column).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realise this doesn't solve the problem of multiple files with different columns but it will confirm this is your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 04:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115204#M31851</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2012-07-23T04:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115205#M31852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@saskiwi Thanks for your reply I apprectiate it. I was aware of that as a solution. However, that wont suit my purposes as I don't want to have to do that for all the files I have, its too manual. I am trying to create an efficient automated process. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 04:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115205#M31852</guid>
      <dc:creator>dom_oh</dc:creator>
      <dc:date>2012-07-23T04:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115206#M31853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a very convenient way(variables list ) to make them all be character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;filename DIRLIST "c:\data\client\folder\Raw Data\*.txt" ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dirlist ;&lt;/P&gt;&lt;P&gt;infile dirlist lrecl=200 truncover;&lt;/P&gt;&lt;P&gt;input var1-var2000 : $200.;&lt;/P&gt;&lt;P&gt;...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 05:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115206#M31853</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-23T05:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115207#M31854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ksharp thanks for replying, That doesn't work for me. All the vars (1:1999) are numeric only var2000 is character. Furthermore, if I did get it working I wouldn't have meaningful variable names and I would have a large number of empty columns. Do you know a way around that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 06:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115207#M31854</guid>
      <dc:creator>dom_oh</dc:creator>
      <dc:date>2012-07-23T06:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115208#M31855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Untested and not efficient:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro readin;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;max;&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE="&amp;amp;&amp;amp;read&amp;amp;i"&lt;/P&gt;&lt;P&gt;OUT=data.&amp;amp;&amp;amp;dset&amp;amp;iv&lt;/P&gt;&lt;P&gt;DBMS=DLM&lt;/P&gt;&lt;P&gt;REPLACE;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;DELIMITER=",";&lt;/P&gt;&lt;P&gt;GUESSINGROWS=10000;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* new code: */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data data.&amp;amp;&amp;amp;dset&amp;amp;iv;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length MemberKey $ 12; /* insert maximum length */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set data.&amp;amp;&amp;amp;dset&amp;amp;iv(rename=(memberkey = MemberKeyNum));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MemberKey = put(MemberKeyNum, z12.); /* fix format length */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop MemberKeyNum;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend readin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%readin;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend moving the import proc to the data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 07:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115208#M31855</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2012-07-23T07:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115209#M31856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="480657" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; Thanks for replying, unfortunately that solution will not work for me because the member keys are of varying lengths to begin with. So if a key is 000123 and another 00123 when padded out to the maximum length again both keys will become 000123.&amp;nbsp; It's pretty much the most frustrating data I have had to deal with given there are so many tables to import! Thanks for the suggestion&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 07:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115209#M31856</guid>
      <dc:creator>dom_oh</dc:creator>
      <dc:date>2012-07-23T07:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115210#M31857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One work around I've seen (I believe in a SAS note) is to add an additional line of data to your .txt file. That could be a string of commas and then you add some text string on the position where you need Proc Import to create a character variable. I believe you need to add "mode=mixed" or some similar syntax to the Proc Import to make this approach work.&lt;/P&gt;&lt;P&gt;Would that be a possible solution for you? It's just about figuring out on which position (after how many commas) you need to add the text string. If I understand right then you have a first header row and you know the column name - so you could just count after how many commas this column name exists in the header row and that gives you the line of text you have to add to your text file (make sure it's withing the guessingrows area).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 08:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115210#M31857</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-07-23T08:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115211#M31858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;All the vars (1:1999) are numeric only var2000 is character.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all you need to estimate the maximum number of all the files. and you can change it to be numberic by using array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Furthermore, if I did get it working I wouldn't have meaningful variable names.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is not a problem. I used to do it usually. You can always use proc datasets to modify them.Such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data varname;&lt;/P&gt;&lt;P&gt;input varname : $40. @@ ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;sds sdsa kjll&amp;nbsp; lkj&amp;nbsp; lkjls sds&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set varname end=last ;&lt;/P&gt;&lt;P&gt;length rename $ 32767;&lt;/P&gt;&lt;P&gt;retain rename;&lt;/P&gt;&lt;P&gt;rename=catx(' ',&amp;nbsp; rename ,'var',_n_,'=',varname);&lt;/P&gt;&lt;P&gt;if last then call symputx('rename',rename);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put &amp;amp;rename ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets library=work nolist;&lt;/P&gt;&lt;P&gt;modify have;&lt;/P&gt;&lt;P&gt; rename &amp;amp;rename&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I would have a large number of empty columns.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is easy. You can use SQL do it. reference my previous example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KSharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 09:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115211#M31858</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-07-23T09:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple file import with leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115212#M31859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just re-read the text files using a data step to get the memberkey variable correct?&lt;/P&gt;&lt;P&gt;You can use PROC CONTENTS or dictionary.columns or SASHELP.VCOLUMN to get the VARNUM for the variable MEMBERKEY in each of you new SAS datasets.&amp;nbsp; Once you have that then you can use code like this to re-read the text file and merge it with the SAS dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let textfile=file1.txt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let ds=file1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let varnum=3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data memberkey ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; infile "&amp;amp;textfile"&amp;nbsp; dlm=',' dsd truncover firstobs=2 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length memberkey $12;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do _n_ = 1 to &amp;amp;varnum;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input memberkey @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data &amp;amp;ds ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; merge memberkey &amp;amp;ds (drop=memberkey);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 12:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-file-import-with-leading-zeros/m-p/115212#M31859</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-07-23T12:53:33Z</dc:date>
    </item>
  </channel>
</rss>

