<?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 concatenate values from multiple observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594734#M170949</link>
    <description>&lt;P&gt;thanks, any other way?&lt;/P&gt;</description>
    <pubDate>Tue, 08 Oct 2019 13:12:47 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2019-10-08T13:12:47Z</dc:date>
    <item>
      <title>How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594731#M170946</link>
      <description>&lt;P&gt;I've a data as follows from one dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;COL_NM&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;operant&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ACCOUNT_PERIOD_CLOSING_BAL_AMT&lt;/TD&gt;&lt;TD&gt;ne&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ACCOUNT_PERIOD_END_DT&lt;/TD&gt;&lt;TD&gt;ne&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;REPORTING_METHOD_CD&lt;/TD&gt;&lt;TD&gt;eq&lt;/TD&gt;&lt;TD&gt;'TAX'&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to apply one condition as below in few programs by reading the above variables so that I no need to write the condition manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where ACCOUNT_PERIOD_CLOSING_BAL_AMT ne . or ACCOUNT_PERIOD_END_DT ne . or REPORTING_METHOD_CD eq 'TAX'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Could you please help me acheive this task?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594731#M170946</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-08T13:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594732#M170947</link>
      <description>&lt;P&gt;Just write the code you want to a file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set have end=eof;
  if _n_=1 then put 'where ' @ ;
  else put '  or ' @;
  put col_nm operant value ;
  if eof then put ';' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use %INCLUDE to add that WHERE statement to any step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=some_other_dataset ;
%include code ;
 tables var1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594732#M170947</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-08T13:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594734#M170949</link>
      <description>&lt;P&gt;thanks, any other way?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594734#M170949</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-08T13:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594737#M170951</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thanks, any other way?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How large is the list of conditions?&amp;nbsp; If it is small enough to fit into a macro variable (64K bytes) then just generate a macro variable instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select catx(' ',col_nm,operant,value)
  into :where separated by ' or '
  from have
;
quit;

proc freq ;
 where &amp;amp;where ;
 tables var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594737#M170951</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-08T13:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594750#M170957</link>
      <description>&lt;P&gt;Do you want to apply these conditions in a data step or in Procedures as well?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594750#M170957</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-08T13:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594778#M170965</link>
      <description>Only in a data step&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2019 15:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594778#M170965</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-08T15:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594810#M170987</link>
      <description>Could you please help me understand what does the else statement do in the&lt;BR /&gt;data step?&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594810#M170987</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-08T16:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594813#M170990</link>
      <description>&lt;P&gt;Are you talking about a specific ELSE statement in a specific data step? Or the general concept of the ELSE statement?&lt;/P&gt;
&lt;P&gt;There is only one data step in this thread. And it has only one ELSE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if _n_=1 then put 'where ' @ ;
  else put '  or ' @;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So _N_=1 will be true only the first iteration of the data step.&amp;nbsp; So this block will either write WHERE or OR at the beginning of the line. The trailing&amp;nbsp;@ on the PUT statement means that a line break is not written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the result is a nice readably formatted file.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where a = 100
   or b &amp;gt; 5
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 16:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594813#M170990</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-08T16:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate values from multiple observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594820#M170993</link>
      <description>I'm talking about the specific else statement which you mentioned in the&lt;BR /&gt;previous post.&lt;BR /&gt;&lt;BR /&gt;Would like to know more about the way you tackle the line break with put&lt;BR /&gt;statement&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Oct 2019 17:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-concatenate-values-from-multiple-observations/m-p/594820#M170993</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-08T17:05:32Z</dc:date>
    </item>
  </channel>
</rss>

