<?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: Space in output file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778577#M247848</link>
    <description>Thank You everyone !&lt;BR /&gt;&lt;BR /&gt;i have used the below code to rename the external file.&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;RC1=rename("&amp;amp;drv2./test/Current/C.txt", "&amp;amp;drv2./test/Current/C.txt", "file");&lt;BR /&gt;run;&lt;BR /&gt;</description>
    <pubDate>Thu, 04 Nov 2021 18:35:42 GMT</pubDate>
    <dc:creator>cho16</dc:creator>
    <dc:date>2021-11-04T18:35:42Z</dc:date>
    <item>
      <title>Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778512#M247817</link>
      <description>&lt;P&gt;Hi Team&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running the below code and am getting space in the output. The &amp;amp;comp. is the global variable.&lt;/P&gt;&lt;P&gt;Is there any way that we can remove the space at the output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set &amp;amp;outdat.;&lt;BR /&gt;file "&amp;amp;drv2./test/Current/&amp;amp;benpk._&amp;amp;comp._00.txt"&amp;nbsp;ls = 4000 mod;&lt;/P&gt;&lt;P&gt;put '"' name +(-1) '",'&lt;BR /&gt;'"' fname +(-1) '",'&lt;BR /&gt;'"'zip +(-1) '",'&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E_42 _00.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NEED:&lt;/P&gt;&lt;P&gt;E_42_00.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 15:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778512#M247817</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2021-11-04T15:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778516#M247818</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HOW do you create &amp;amp;comp? An unwanted space would mean the approach to creating it needs to be addressed. Prevent not fix is a better approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %trim macro function might work unless the "space" shown in the name is a different null character.&lt;/P&gt;
&lt;P&gt;%let comp=%trim(&amp;amp;comp.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778516#M247818</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-04T16:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778519#M247820</link>
      <description>&lt;P&gt;If COMP just has an regular space without macro quoting it is much easier to just use the %LET statement itself to remove the trailing/leading spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let comp=&amp;amp;comp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't really like to use %TRIM() as it is an autocall macro and not an actual macro function.&amp;nbsp; So if someone has accidentally left the SYMBOLGEN and/or MLOGIC options turned on your SAS log can get cluttered with a lot of extra lines depending on the number of trailing spaces it has to remove.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:12:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778519#M247820</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-04T16:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778522#M247823</link>
      <description>Yes i tried the trim function, still getting a space.&lt;BR /&gt;&lt;BR /&gt;Is there any option to change the output text file name from SAS data step ?</description>
      <pubDate>Thu, 04 Nov 2021 16:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778522#M247823</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2021-11-04T16:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778529#M247829</link>
      <description>&lt;P&gt;The TRIM() function works on actual variables or strings. Not on macro variables.&amp;nbsp; And if you assign the result back to a variable then the spaces will return if the result is shorter than the defined length of the variable.&amp;nbsp; SAS variables are fixed length so short values are padded with spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the CALL SYMPUTX() when generating macro variables from a data step.&lt;/P&gt;
&lt;P&gt;Use the TRIMMED keyword when generating macro variable from PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To set the name of the output file dynamically in a data step use the FILEVAR= option on the FILE statement.&amp;nbsp; If you want comma delimited values use the DSD option.&amp;nbsp; If you want to force quotes around values that don't need them then use the ~ modifier on the PUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your &amp;amp;BENPK and &amp;amp;COMP macro variables are just the values of the BENPK and COMP dataset variables then your code can be like this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set &amp;amp;outdat.;
  length filename $256 ;
  filename=cats("&amp;amp;drv2./test/Current/",benpk,'_',comp,'_00.txt');
  file out filevar=filename dsd mod;
  put (name fname zip) (~) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If they aren't dataset variables the instead of BENPK and COMP in the list of values for CATS() to concatenate then use "&amp;amp;BENPK" and "&amp;amp;COMP".&amp;nbsp; Or use SYMGET('BENPK') and SYMGET('COMP').&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778529#M247829</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-04T16:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Space in output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778577#M247848</link>
      <description>Thank You everyone !&lt;BR /&gt;&lt;BR /&gt;i have used the below code to rename the external file.&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;RC1=rename("&amp;amp;drv2./test/Current/C.txt", "&amp;amp;drv2./test/Current/C.txt", "file");&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Nov 2021 18:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Space-in-output-file/m-p/778577#M247848</guid>
      <dc:creator>cho16</dc:creator>
      <dc:date>2021-11-04T18:35:42Z</dc:date>
    </item>
  </channel>
</rss>

