<?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 array function, %nrstr and _: using in same syntax for a single check in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-function-nrstr-and-using-in-same-syntax-for-a-single-check/m-p/674838#M203245</link>
    <description>&lt;P&gt;&lt;FONT color="#99CC00"&gt;*I want to print out any of the tree_: which falls under any of the following types of trees '999', '888' etc.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#99CC00"&gt;*The following code I have used;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;%let&lt;/FONT&gt; trees = &lt;FONT color="#3366FF"&gt;%nrstr&lt;/FONT&gt; ('999', '888', '111', '222', '555', '876', '564', '109',&lt;BR /&gt;'456', '543', '897', '009', '321'); &lt;FONT color="#99CC00"&gt;*I will check many more types of trees like the '999' etc.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; &lt;/FONT&gt;want;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; have;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; hl {*} tree_:; &lt;FONT color="#99CC00"&gt;*here tree_: can be even up to 50 (tree_50) and it is not fixed;&lt;/FONT&gt;&lt;BR /&gt;tree_ = &amp;amp;trees;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; to dim(hl);&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; hl(i) ne &amp;amp;trees &lt;FONT color="#0000FF"&gt;then&lt;/FONT&gt; tree_ = &lt;FONT color="#339966"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;tree = whichc(&lt;FONT color="#800080"&gt;'&amp;amp;trees'&lt;/FONT&gt;, of hl(*))&amp;gt;&lt;FONT color="#339966"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#003366"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#99CC00"&gt;The following is what showing in log, there were some numbers at the beginning of each SAS statement that I have replaced with *** as I am not sure if I can publish it;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;%let&lt;/FONT&gt; trees = &lt;FONT color="#0000FF"&gt;%nrstr&lt;/FONT&gt;('999', '888', '111', '222', '555', '876', '564', '109',&lt;BR /&gt;'456', '543', '897', '009', '321');&lt;BR /&gt;&lt;FONT color="#008000"&gt;**** &lt;/FONT&gt;data want;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&amp;nbsp;&lt;/FONT&gt;set have;&lt;BR /&gt;&lt;FONT color="#99cc00"&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt;array hl {*} tree_:;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; tree_ = &amp;amp;trees;&lt;BR /&gt;NOTE: &lt;FONT color="#FF0000"&gt;Line&lt;/FONT&gt; generated by the macro variable "trees".&lt;BR /&gt;1&lt;FONT color="#800080"&gt; '999', '888', '111', '222', '555', '876', '564',&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;388&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;76&lt;/FONT&gt;&lt;BR /&gt;1 ! &lt;FONT color="#800080"&gt;'456', '543', '897', '009', '321'&lt;/FONT&gt;&lt;BR /&gt;ERROR &lt;FONT color="#008000"&gt;388-185:&lt;/FONT&gt; Expecting an arithmetic &lt;FONT color="#008000"&gt;operator&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;ERROR &lt;FONT color="#008000"&gt;76-322:&lt;/FONT&gt; Syntax error, statement will be &lt;FONT color="#008000"&gt;ignored&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; do i=&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; to dim(hl);&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; if hl(i) ne &amp;amp;trees then tree_ = &lt;FONT color="#008000"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;NOTE: &lt;FONT color="#FF0000"&gt;Line&lt;/FONT&gt; generated by the macro variable &lt;FONT color="#800080"&gt;"trees"&lt;/FONT&gt;.&lt;BR /&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &lt;FONT color="#800080"&gt;'999', '888', '111', '222', '555', '876', '564',&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;388&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;76&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; ! &lt;FONT color="#800080"&gt;'456', '543', '897', '009', '321'&lt;/FONT&gt;&lt;BR /&gt;ERROR &lt;FONT color="#008000"&gt;388-185:&lt;/FONT&gt; Expecting an arithmetic &lt;FONT color="#008000"&gt;operator&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;ERROR &lt;FONT color="#008000"&gt;76-322&lt;/FONT&gt;: Syntax error, statement will be &lt;FONT color="#008000"&gt;ignored&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; tree = whichc('&amp;amp;trees', of hl(*))&lt;FONT color="#008000"&gt;&amp;gt;0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; end;&lt;BR /&gt;**** run;&lt;/P&gt;&lt;P&gt;NOTE: &lt;FONT color="#FF0000"&gt;The&lt;/FONT&gt; SAS System stopped processing this step because of &lt;FONT color="#008000"&gt;errors&lt;/FONT&gt;.&lt;BR /&gt;WARNING: The data set WORK.want may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and&lt;FONT color="#008000"&gt;&amp;nbsp;***&amp;nbsp;variables.&lt;/FONT&gt;&lt;BR /&gt;WARNING: Data set WORK.want was not replaced because this step was &lt;FONT color="#008000"&gt;stopped&lt;/FONT&gt;.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time ** seconds&lt;BR /&gt;cpu time ** seconds&lt;/P&gt;&lt;P&gt;&lt;FONT color="#99CC00"&gt;*can anyone please suggest what may be the wrong with the code?;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2020 20:13:41 GMT</pubDate>
    <dc:creator>nirsan</dc:creator>
    <dc:date>2020-08-05T20:13:41Z</dc:date>
    <item>
      <title>array function, %nrstr and _: using in same syntax for a single check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-function-nrstr-and-using-in-same-syntax-for-a-single-check/m-p/674838#M203245</link>
      <description>&lt;P&gt;&lt;FONT color="#99CC00"&gt;*I want to print out any of the tree_: which falls under any of the following types of trees '999', '888' etc.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#99CC00"&gt;*The following code I have used;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;%let&lt;/FONT&gt; trees = &lt;FONT color="#3366FF"&gt;%nrstr&lt;/FONT&gt; ('999', '888', '111', '222', '555', '876', '564', '109',&lt;BR /&gt;'456', '543', '897', '009', '321'); &lt;FONT color="#99CC00"&gt;*I will check many more types of trees like the '999' etc.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; &lt;/FONT&gt;want;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;set&lt;/FONT&gt; have;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;array&lt;/FONT&gt; hl {*} tree_:; &lt;FONT color="#99CC00"&gt;*here tree_: can be even up to 50 (tree_50) and it is not fixed;&lt;/FONT&gt;&lt;BR /&gt;tree_ = &amp;amp;trees;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;do&lt;/FONT&gt; i=&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; to dim(hl);&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; hl(i) ne &amp;amp;trees &lt;FONT color="#0000FF"&gt;then&lt;/FONT&gt; tree_ = &lt;FONT color="#339966"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;tree = whichc(&lt;FONT color="#800080"&gt;'&amp;amp;trees'&lt;/FONT&gt;, of hl(*))&amp;gt;&lt;FONT color="#339966"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;&lt;BR /&gt;&lt;FONT color="#003366"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#99CC00"&gt;The following is what showing in log, there were some numbers at the beginning of each SAS statement that I have replaced with *** as I am not sure if I can publish it;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;%let&lt;/FONT&gt; trees = &lt;FONT color="#0000FF"&gt;%nrstr&lt;/FONT&gt;('999', '888', '111', '222', '555', '876', '564', '109',&lt;BR /&gt;'456', '543', '897', '009', '321');&lt;BR /&gt;&lt;FONT color="#008000"&gt;**** &lt;/FONT&gt;data want;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&amp;nbsp;&lt;/FONT&gt;set have;&lt;BR /&gt;&lt;FONT color="#99cc00"&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt;array hl {*} tree_:;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; tree_ = &amp;amp;trees;&lt;BR /&gt;NOTE: &lt;FONT color="#FF0000"&gt;Line&lt;/FONT&gt; generated by the macro variable "trees".&lt;BR /&gt;1&lt;FONT color="#800080"&gt; '999', '888', '111', '222', '555', '876', '564',&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;388&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;76&lt;/FONT&gt;&lt;BR /&gt;1 ! &lt;FONT color="#800080"&gt;'456', '543', '897', '009', '321'&lt;/FONT&gt;&lt;BR /&gt;ERROR &lt;FONT color="#008000"&gt;388-185:&lt;/FONT&gt; Expecting an arithmetic &lt;FONT color="#008000"&gt;operator&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;ERROR &lt;FONT color="#008000"&gt;76-322:&lt;/FONT&gt; Syntax error, statement will be &lt;FONT color="#008000"&gt;ignored&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; do i=&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; to dim(hl);&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; if hl(i) ne &amp;amp;trees then tree_ = &lt;FONT color="#008000"&gt;0&lt;/FONT&gt;;&lt;BR /&gt;NOTE: &lt;FONT color="#FF0000"&gt;Line&lt;/FONT&gt; generated by the macro variable &lt;FONT color="#800080"&gt;"trees"&lt;/FONT&gt;.&lt;BR /&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &lt;FONT color="#800080"&gt;'999', '888', '111', '222', '555', '876', '564',&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;388&lt;/FONT&gt;&lt;BR /&gt;-&lt;BR /&gt;&lt;FONT color="#008000"&gt;76&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt; ! &lt;FONT color="#800080"&gt;'456', '543', '897', '009', '321'&lt;/FONT&gt;&lt;BR /&gt;ERROR &lt;FONT color="#008000"&gt;388-185:&lt;/FONT&gt; Expecting an arithmetic &lt;FONT color="#008000"&gt;operator&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;ERROR &lt;FONT color="#008000"&gt;76-322&lt;/FONT&gt;: Syntax error, statement will be &lt;FONT color="#008000"&gt;ignored&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; tree = whichc('&amp;amp;trees', of hl(*))&lt;FONT color="#008000"&gt;&amp;gt;0;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;****&lt;/FONT&gt; end;&lt;BR /&gt;**** run;&lt;/P&gt;&lt;P&gt;NOTE: &lt;FONT color="#FF0000"&gt;The&lt;/FONT&gt; SAS System stopped processing this step because of &lt;FONT color="#008000"&gt;errors&lt;/FONT&gt;.&lt;BR /&gt;WARNING: The data set WORK.want may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and&lt;FONT color="#008000"&gt;&amp;nbsp;***&amp;nbsp;variables.&lt;/FONT&gt;&lt;BR /&gt;WARNING: Data set WORK.want was not replaced because this step was &lt;FONT color="#008000"&gt;stopped&lt;/FONT&gt;.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time ** seconds&lt;BR /&gt;cpu time ** seconds&lt;/P&gt;&lt;P&gt;&lt;FONT color="#99CC00"&gt;*can anyone please suggest what may be the wrong with the code?;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 20:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-function-nrstr-and-using-in-same-syntax-for-a-single-check/m-p/674838#M203245</guid>
      <dc:creator>nirsan</dc:creator>
      <dc:date>2020-08-05T20:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: array function, %nrstr and _: using in same syntax for a single check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-function-nrstr-and-using-in-same-syntax-for-a-single-check/m-p/674848#M203248</link>
      <description>&lt;P&gt;Your statement&lt;/P&gt;
&lt;P&gt;tree_ = &amp;amp;trees;&lt;/P&gt;
&lt;P&gt;is resolving to &lt;/P&gt;
&lt;P&gt;tree_ = '999', '888', '111', '222', '555', '876', '564', '109','456', '543', '897', '009', '321' ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;similarly&lt;/P&gt;
&lt;P&gt;hl(i) ne &amp;amp;trees is&lt;/P&gt;
&lt;P&gt;hl(i) ne '999', '888', '111', '222', '555', '876', '564', '109','456', '543', '897', '009', '321' &lt;/P&gt;
&lt;P&gt;If you don't know why either of those is an error you need to review a lot of basics before attempting to use macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea what you are attempting to do with the tree_ = . If you are attempting to use R like syntax to assign values to the array then that is not going to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using instead of the comparison this:&lt;/P&gt;
&lt;P&gt;hl(i) not in ( &amp;amp;trees) then&amp;nbsp; &lt;/P&gt;
&lt;P&gt;might work if you want to find out that a single value of the array does not appear in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then&lt;/P&gt;
&lt;P&gt;tree = whichc(&lt;FONT color="#800080"&gt;'&amp;amp;trees'&lt;/FONT&gt;, of hl(*))&amp;gt;&lt;FONT color="#339966"&gt;0&lt;/FONT&gt;;&lt;/P&gt;
&lt;P&gt;first has a problem because&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; whichc('&amp;amp;trees'&amp;nbsp;&amp;nbsp; resolves to nothing. it uses the literal value &amp;amp;trees because macro variables do not resolve at all inside single quotes.&lt;/P&gt;
&lt;P&gt;If you used whichc("&amp;amp;trees" then the whichc would be looking for the entire value "'999', '888', '111', '222', '555', '876', '564', '109','456', '543', '897', '009', '321' " to be in a single value of the one of the array elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to describe exactly what you are attempting to do. Best would be to show code that worked before you added in any macro variables. If you don't have such code, then that is the first thing you need to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2020 20:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-function-nrstr-and-using-in-same-syntax-for-a-single-check/m-p/674848#M203248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-05T20:03:01Z</dc:date>
    </item>
  </channel>
</rss>

