<?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: Importar de TXT a SAS gran cantidad de ficheros,  con el mismo nombre que tiene e TXT in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Importar-de-TXT-a-SAS-gran-cantidad-de-ficheros-con-el-mismo/m-p/778642#M31545</link>
    <description>&lt;P&gt;Sólo sería necesario extraer el nombre del archivo y colocarlo en cada iteración. Agregaría dos líneas:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt; %LET&lt;/FONT&gt; len=&lt;FONT color="#0000FF"&gt;%LENGTH&lt;/FONT&gt;(&amp;amp;nombre); &lt;FONT color="#008080"&gt;/* Longitud de la cadena */&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; name=&lt;FONT color="#0000FF"&gt;%SUBSTR&lt;/FONT&gt;(&amp;amp;nombre,1,&amp;amp;len-4); &lt;FONT color="#008080"&gt;/* Obtención del nombre */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Quedando el código de la siguiente manera:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;%MACRO&lt;/FONT&gt;&lt;/STRONG&gt; importarTXT(Directorio);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FILENAME REFDIR "&amp;amp;Directorio";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; DIRID=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DOPEN(REFDIR));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; NFILES=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DNUM(&amp;amp;DIRID));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%DO&lt;/FONT&gt; I=1 &lt;FONT color="#0000FF"&gt;%TO&lt;/FONT&gt; &amp;amp;Nfiles;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; nombre=%sysfunc(DREAD(&amp;amp;DIRID,&amp;amp;i));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; len=&lt;FONT color="#0000FF"&gt;%LENGTH&lt;/FONT&gt;(&amp;amp;nombre); &lt;FONT color="#008080"&gt;/* Longitud de la cadena */&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; name=&lt;FONT color="#0000FF"&gt;%SUBSTR&lt;/FONT&gt;(&amp;amp;nombre,1,&amp;amp;len-4); &lt;FONT color="#008080"&gt;/* Obtención del nombre */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;PROC IMPORT OUT= WORK.&amp;amp;&amp;amp;name&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DATAFILE= "&amp;amp;Directorio\&amp;amp;nombre"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DBMS=TAB REPLACE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DELIMITER='7C'x;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;GETNAMES=yes;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;RUN;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;%end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; DIRCLOSE=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DCLOSE(&amp;amp;DIRID));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;%MEND&lt;/FONT&gt;&lt;/STRONG&gt; importarTXT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;%importarTXT&lt;/STRONG&gt;(Directorio=C:\temp);&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 23:56:23 GMT</pubDate>
    <dc:creator>Alejandro</dc:creator>
    <dc:date>2021-11-04T23:56:23Z</dc:date>
    <item>
      <title>Importar de TXT a SAS gran cantidad de ficheros,  con el mismo nombre que tiene e TXT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importar-de-TXT-a-SAS-gran-cantidad-de-ficheros-con-el-mismo/m-p/778480#M31530</link>
      <description>&lt;P&gt;Hola tengo una macro para importar ficheros txt de un directorio, mi problema es que cuando crea los ficheros SAS estos se crea con un nombre secuencial, y a mi me gustaria que conservara el nombre que tiene el txt.&lt;/P&gt;&lt;P&gt;Este sería mi programa:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; importarTXT(Directorio);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;FILENAME REFDIR &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;Directorio"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DIRID=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(DOPEN(REFDIR)); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; NFILES=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(DNUM(&amp;amp;DIRID)); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%DO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; I=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%TO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;Nfiles;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; nombre=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(DREAD(&amp;amp;DIRID,&amp;amp;i)); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= fichero&amp;amp;i&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DATAFILE= &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;Directorio\&amp;amp;nombre"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DBMS=TAB REPLACE;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DELIMITER=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'7C'x&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GETNAMES=yes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%LET&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; DIRCLOSE=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(DCLOSE(&amp;amp;DIRID));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%MEND&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; importarTXT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;importarTXT&lt;/I&gt;&lt;/STRONG&gt;(Directorio=C:\JUANA\macro);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 12:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importar-de-TXT-a-SAS-gran-cantidad-de-ficheros-con-el-mismo/m-p/778480#M31530</guid>
      <dc:creator>JU2</dc:creator>
      <dc:date>2021-11-04T12:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Importar de TXT a SAS gran cantidad de ficheros,  con el mismo nombre que tiene e TXT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importar-de-TXT-a-SAS-gran-cantidad-de-ficheros-con-el-mismo/m-p/778642#M31545</link>
      <description>&lt;P&gt;Sólo sería necesario extraer el nombre del archivo y colocarlo en cada iteración. Agregaría dos líneas:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt; %LET&lt;/FONT&gt; len=&lt;FONT color="#0000FF"&gt;%LENGTH&lt;/FONT&gt;(&amp;amp;nombre); &lt;FONT color="#008080"&gt;/* Longitud de la cadena */&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; name=&lt;FONT color="#0000FF"&gt;%SUBSTR&lt;/FONT&gt;(&amp;amp;nombre,1,&amp;amp;len-4); &lt;FONT color="#008080"&gt;/* Obtención del nombre */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Quedando el código de la siguiente manera:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;%MACRO&lt;/FONT&gt;&lt;/STRONG&gt; importarTXT(Directorio);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FILENAME REFDIR "&amp;amp;Directorio";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; DIRID=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DOPEN(REFDIR));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; NFILES=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DNUM(&amp;amp;DIRID));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%DO&lt;/FONT&gt; I=1 &lt;FONT color="#0000FF"&gt;%TO&lt;/FONT&gt; &amp;amp;Nfiles;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; nombre=%sysfunc(DREAD(&amp;amp;DIRID,&amp;amp;i));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; len=&lt;FONT color="#0000FF"&gt;%LENGTH&lt;/FONT&gt;(&amp;amp;nombre); &lt;FONT color="#008080"&gt;/* Longitud de la cadena */&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; name=&lt;FONT color="#0000FF"&gt;%SUBSTR&lt;/FONT&gt;(&amp;amp;nombre,1,&amp;amp;len-4); &lt;FONT color="#008080"&gt;/* Obtención del nombre */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;PROC IMPORT OUT= WORK.&amp;amp;&amp;amp;name&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DATAFILE= "&amp;amp;Directorio\&amp;amp;nombre"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DBMS=TAB REPLACE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;DELIMITER='7C'x;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;GETNAMES=yes;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;RUN;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;%end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%LET&lt;/FONT&gt; DIRCLOSE=&lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(DCLOSE(&amp;amp;DIRID));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;%MEND&lt;/FONT&gt;&lt;/STRONG&gt; importarTXT;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;%importarTXT&lt;/STRONG&gt;(Directorio=C:\temp);&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 23:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importar-de-TXT-a-SAS-gran-cantidad-de-ficheros-con-el-mismo/m-p/778642#M31545</guid>
      <dc:creator>Alejandro</dc:creator>
      <dc:date>2021-11-04T23:56:23Z</dc:date>
    </item>
  </channel>
</rss>

