<?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: ERROR 22-322/ERROR 76-322: Macro Variable &amp;amp;n generates random white spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625255#M184279</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank a lot for you quick help!!!&lt;/P&gt;&lt;P&gt;The first solution already worked! I have been sitting hours in front of this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2020 13:29:12 GMT</pubDate>
    <dc:creator>Debugger</dc:creator>
    <dc:date>2020-02-17T13:29:12Z</dc:date>
    <item>
      <title>ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625244#M184271</link>
      <description>&lt;P&gt;Hi @ all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to generate Macro Variables via a Proc SQL in SAS EG however there seems to be a problem, when I try to generate several of these.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql&lt;/STRONG&gt;;&lt;BR /&gt;select count(*) into :n&lt;BR /&gt;from work.Tabelle1;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc SQL&lt;/STRONG&gt;;&lt;BR /&gt;Select distinct NAME into :name1 - :name&amp;amp;n&lt;BR /&gt;from work.Tabelle1;&lt;BR /&gt;Quit;&lt;BR /&gt;&lt;STRONG&gt;Proc SQL&lt;/STRONG&gt;;&lt;BR /&gt;select distinct Tabellenname into :Joinfeld1 - :Joinfeld&amp;amp;n&lt;BR /&gt;from work.Tabelle1;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Logs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;27 proc sql;&lt;BR /&gt;28 select count(*) into :n&lt;BR /&gt;29 from work.Tabelle1;&lt;BR /&gt;30 Quit;&lt;BR /&gt;&lt;FONT color="#339966"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;31&lt;BR /&gt;32 proc SQL;&lt;BR /&gt;33 Select distinct NAME into :name1 - :name&amp;amp;n&lt;BR /&gt;34 from work.Tabelle1;&lt;BR /&gt;&lt;FONT color="#339966"&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;NOTE: Line generated by the macro variable "N".&lt;/FONT&gt;&lt;BR /&gt;34 name 264&lt;BR /&gt;___&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', FROM, NOTRIM.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;35 Quit;&lt;BR /&gt;&lt;FONT color="#008000"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;36 Proc SQL;&lt;BR /&gt;37 select distinct Tabellenname into :Joinfeld1 - :Joinfeld&amp;amp;n&lt;BR /&gt;38 from work.Tabelle1;&lt;BR /&gt;&lt;FONT color="#008000"&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;NOTE: Line generated by the macro variable "N".&lt;/FONT&gt;&lt;BR /&gt;38 Joinfeld 264&lt;BR /&gt;___&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', FROM, NOTRIM.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;39 Quit;&lt;BR /&gt;&lt;FONT color="#339966"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625244#M184271</guid>
      <dc:creator>Debugger</dc:creator>
      <dc:date>2020-02-17T12:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625246#M184273</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312493"&gt;@Debugger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try to add the TRIMMED option in the below code. It will remove trailing blanks from the macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select count(*) into :n trimmed&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In addition, you can also put only this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select distinct NAME into :name1 -
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct Tabellenname into :Joinfeld1 -&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625246#M184273</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-17T12:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625250#M184275</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312493"&gt;@Debugger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;wrote, you can use hyphen(-) notation to get the list of macrovariables and then `&amp;amp;sqlobs.` may help to get the number of variables created:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select distinct age 
  into :age1-
  from sashelp.class
  ;
  %let N_age = &amp;amp;sqlobs.;
quit;
%put _user_;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;One side note. You are counting all obs from the dataset in the first query and in the second you take distinct list, are those values the same?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625250#M184275</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-02-17T12:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625251#M184276</link>
      <description>&lt;P&gt;Another, very simple, method to get rid of leading and trailing blanks in macro variables is this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=&amp;amp;n;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Feb 2020 12:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625251#M184276</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-17T12:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625255#M184279</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank a lot for you quick help!!!&lt;/P&gt;&lt;P&gt;The first solution already worked! I have been sitting hours in front of this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 13:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625255#M184279</guid>
      <dc:creator>Debugger</dc:creator>
      <dc:date>2020-02-17T13:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625264#M184281</link>
      <description>&lt;P&gt;That's what the communities are meant for. Please accept the message that helped you most (or first) as the solution.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 13:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625264#M184281</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-17T13:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625309#M184299</link>
      <description>&lt;P&gt;Hi;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; they&amp;nbsp; should be the same value. The idea is that i want to get a list of distinct variables, that i can build a loop on, as I experienced however my code only count to the end of the oservations. any idea how i could change that? Is that possible with the Sqlobs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanksin advance&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 15:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625309#M184299</guid>
      <dc:creator>Debugger</dc:creator>
      <dc:date>2020-02-17T15:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 22-322/ERROR 76-322: Macro Variable &amp;n generates random white spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625358#M184308</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312493"&gt;@Debugger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to get variables list (not observations) I would try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  variable1 = 17;
  variable2 = 42;
  variable3 = 303;
run;

proc contents 
  data = test /* dataset from which you want variables list */
  out = variablesList(keep = name)
  noprint;
run;

data _null_;
 set variablesList end=eof nobs=nobs;
 call symputX(cats("name", _N_), name, "L");
 if eof;
 call symputX("n", nobs, "L");
run;

%put _user_;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 17:12:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-22-322-ERROR-76-322-Macro-Variable-amp-n-generates-random/m-p/625358#M184308</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-02-17T17:12:15Z</dc:date>
    </item>
  </channel>
</rss>

