<?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: using _N_ in a string (remove the spaces!) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415564#M280150</link>
    <description>&lt;P&gt;Use one the series of concatenate functions that SAS has.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1569  data _null_;
1570   do _n_=1 to 3 ;
1571     length formula $ 50;
1572     formula = cats('=CONCATENATE($B',_N_,',$G',_N_,')');
1573     put _n_= formula = :$quote.;
1574   end;
1575  run;

_N_=1 formula="=CONCATENATE($B1,$G1)"
_N_=2 formula="=CONCATENATE($B2,$G2)"
_N_=3 formula="=CONCATENATE($B3,$G3)"
&lt;/PRE&gt;
&lt;P&gt;They will also silently convert numbers to strings for you unlike when you apply a character function like trim() to them.&amp;nbsp; But if your numbers are not integers or can get too big then you should use PUT() function to convert your numbers to string rather than letting SAS guess at what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2017 16:28:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-11-22T16:28:17Z</dc:date>
    <item>
      <title>using _N_ in a string (remove the spaces!)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415544#M280146</link>
      <description>&lt;P&gt;data blah;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;set blahblah;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;length formula $ 50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;formula = "=CONCATENATE($B" || trim(_N_) || ",$G" || trim(_N_) || ")";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;results in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=CONCATENATE($B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1,$G&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how do i get rid of those spaces? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 15:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415544#M280146</guid>
      <dc:creator>StaticFX</dc:creator>
      <dc:date>2017-11-22T15:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: using _N_ in a string (remove the spaces!)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415545#M280147</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   string="=CONCATENATE($B" || trim(_N_) || ",$G" || trim(_N_) || ")";
   newstring=compress(string);
   put string;
   put newstring;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Nov 2017 15:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415545#M280147</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-22T15:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: using _N_ in a string (remove the spaces!)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415548#M280148</link>
      <description>&lt;P&gt;compress!! thats what i was thinking... but why not just do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;string="=CONCATENATE($B" || compress(_N_) || ",$G" || compress(_N_) || ")";&lt;/PRE&gt;&lt;P&gt;it works...&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 15:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415548#M280148</guid>
      <dc:creator>StaticFX</dc:creator>
      <dc:date>2017-11-22T15:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: using _N_ in a string (remove the spaces!)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415556#M280149</link>
      <description>&lt;P&gt;Just a note that if you're making Excel cell references, it tends to use RC notation for interaction with some things such as DDE. Not sure what ODS EXCEL or TAGSETS use.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 16:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415556#M280149</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-22T16:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: using _N_ in a string (remove the spaces!)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415564#M280150</link>
      <description>&lt;P&gt;Use one the series of concatenate functions that SAS has.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1569  data _null_;
1570   do _n_=1 to 3 ;
1571     length formula $ 50;
1572     formula = cats('=CONCATENATE($B',_N_,',$G',_N_,')');
1573     put _n_= formula = :$quote.;
1574   end;
1575  run;

_N_=1 formula="=CONCATENATE($B1,$G1)"
_N_=2 formula="=CONCATENATE($B2,$G2)"
_N_=3 formula="=CONCATENATE($B3,$G3)"
&lt;/PRE&gt;
&lt;P&gt;They will also silently convert numbers to strings for you unlike when you apply a character function like trim() to them.&amp;nbsp; But if your numbers are not integers or can get too big then you should use PUT() function to convert your numbers to string rather than letting SAS guess at what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 16:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-N-in-a-string-remove-the-spaces/m-p/415564#M280150</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-22T16:28:17Z</dc:date>
    </item>
  </channel>
</rss>

