<?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: How to avoid space in .txt file during PROC EXPORT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272778#M54291</link>
    <description>&lt;P&gt;Use a formatted PUT statement instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file 'want.txt' ;
  set have ;
  put patient_ID $3. (Var_1-Var_3) ($7.) ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 May 2016 16:08:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-05-24T16:08:12Z</dc:date>
    <item>
      <title>How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272767#M54285</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have the following dataset. Each Varable length is exact length. For example patient_id has length 3 and variable_1 has legth 7.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When I export the dataset to .txt I get space between two variable (since I indicate dbms=tab in my output). Can anyone tell me how do I specify in PROC EXPORT so that I can avoid spcae in .txt file. Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;patient_ID Var_1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Var_2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Var_3 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;101 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LP28M72 &amp;nbsp; LP23M66 &amp;nbsp; LP22M64&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;101 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LP29M64 &amp;nbsp; NOTUSED NOTUSED&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SR66F76 &amp;nbsp; SR62F76 &amp;nbsp; SR61F76 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;102 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SR69F76 &amp;nbsp; SR77F76 &amp;nbsp; NOTUSED &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;103 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; JH23F56 &amp;nbsp; JH43F56 &amp;nbsp; NOTUSED&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;here is my code:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PROC EXPORT &lt;BR /&gt;data=have&lt;BR /&gt;outfile='C:\Users\want.txt' &lt;BR /&gt;dbms=tab replace;&lt;BR /&gt;putnames=no;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;EXPECTED OUTPUT:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;101LP28M72LP23M66LP22M64&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;101LP29M64NOTUSEDNOTUSED&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;102SR66F76SR62F76SR61F76 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;102SR69F76SR77F76NOTUSED &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;103JH23F56JH43F56NOTUSED&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 15:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272767#M54285</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-24T15:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272772#M54287</link>
      <description>&lt;P&gt;If you don't want space between variables then why specify TAB in the first place?&lt;/P&gt;
&lt;P&gt;If I understand your requirement you may need to go old school as Proc Export want some sort of file type and a delimiter, so you would get a character between values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may give you what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set have;
   file 'C:\Users\want.txt' ;
   length line $ 25; /* large enough to hold all the variables*/
   line = catt(patientid,var_1,var_2,var_3);
   put line;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Though Fixed column isn't popular anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 15:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272772#M54287</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-24T15:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272775#M54289</link>
      <description>Hi ballardw,&lt;BR /&gt;Thanks for your reply. If I use catt then my variable will be 750 character long as my each variable is actually 35 character long, that's why I don't think putting all variables in one will work for me. That's why I wanted to go for PROC EXPORT. Anyways, do you know a way which will keep the variable side by side without any space? Thanks.</description>
      <pubDate>Tue, 24 May 2016 15:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272775#M54289</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-24T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272778#M54291</link>
      <description>&lt;P&gt;Use a formatted PUT statement instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file 'want.txt' ;
  set have ;
  put patient_ID $3. (Var_1-Var_3) ($7.) ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 16:08:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272778#M54291</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-24T16:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272780#M54292</link>
      <description>&lt;P&gt;There's nothing wrong with making line 750 characters long. The only trick is making the CATT statement.&lt;/P&gt;
&lt;P&gt;If you aren't making a whole bunch of these files then use proc export with a space or other character and then use a text editor to remove all of them. Not slick and the extra step isn't really a good idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The real old school approach was to use Put statements with fixed column start points, which may be a good idea if you ever run into a variable with varying length:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Put @1 Id @36 Var_1 @71 var_2 @106 var_3 &amp;lt;etc&amp;gt;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;Would place them at fixed positions. There is syntax that lets specify that with parantheses and variable lists but research the PUT statement for more details on Column output.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 16:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272780#M54292</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-24T16:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272870#M54311</link>
      <description>Hi Tom,&lt;BR /&gt;Would you please tell me If I want to allow 12 spaces between patient_ID and Var_1 how can I do that?&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Tue, 24 May 2016 19:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272870#M54311</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-24T19:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272871#M54312</link>
      <description>&lt;P&gt;Look at the manual on the PUT statement.&lt;/P&gt;
&lt;P&gt;If you want to skip 12 spaces then just at +12 to the PUT statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put id $3. +12 var1 $7. ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to tell SAS to use 15 instead of 3 columns for the ID variable then just use a longer format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put id $15. ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can also tell it to go the particular column where you want to put the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put id $3. @16 var1 $7. ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can combine them in many ways. &amp;nbsp;Just don't try to put more characters than can fit or else the values will overwrite each other.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put @15 var1 @1 id @22 var2 ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 20:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272871#M54312</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-24T20:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272875#M54314</link>
      <description>Thanks Tom. it worked.</description>
      <pubDate>Tue, 24 May 2016 20:15:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272875#M54314</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-24T20:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272918#M54327</link>
      <description>Hi Tom,&lt;BR /&gt;I added few variables using PUT function, but it doesn't work after it reaches $ 256. Do you have any idea why? Thanks.</description>
      <pubDate>Wed, 25 May 2016 00:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272918#M54327</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-25T00:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272919#M54328</link>
      <description>Hi ballardw,&lt;BR /&gt;I added few variables using PUT function, but it doesn't work after it reaches $ 256. Do you have any idea why? Thanks.</description>
      <pubDate>Wed, 25 May 2016 00:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272919#M54328</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-25T00:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272920#M54329</link>
      <description>&lt;P&gt;Most likely that is the default for the&amp;nbsp;LRECL option on your verison of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the LRECL= option to the FILE statement. &amp;nbsp;You can set it really large as SAS will only write the number of characters you actually tell it to in the PUT statement.&amp;nbsp;32767 is a nice number to use since it is 2**15-1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;file 'myfile.txt' lrecl=32767 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 01:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/272920#M54329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-25T01:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/273268#M54435</link>
      <description>Hi Tom,&lt;BR /&gt;Is it possible to define a variable length during concatenation? Like: var1=var2 5.||var3 10.; ? Thanks.</description>
      <pubDate>Thu, 26 May 2016 14:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/273268#M54435</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-26T14:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid space in .txt file during PROC EXPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/274160#M54669</link>
      <description>Hi ballardw,&lt;BR /&gt;I like your this code as an alternate of proc export. Is there any such code available for PROC IMPORT which can be an alternative of the following:&lt;BR /&gt;&lt;BR /&gt;PROC IMPORT DATAFILE="C:\have.xlsx"&lt;BR /&gt;DBMS=xlsx replace&lt;BR /&gt;OUT=want (RENAME=(var3=var4) KEEP=var4 WHERE=(var1='abcd');&lt;BR /&gt;SHEET='steet1';&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 31 May 2016 17:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-space-in-txt-file-during-PROC-EXPORT/m-p/274160#M54669</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2016-05-31T17:11:14Z</dc:date>
    </item>
  </channel>
</rss>

