<?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 Concatenate Macro Output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38924#M7873</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sks,&lt;/P&gt;&lt;P&gt;There is a possible problem with using CONTAINS.&amp;nbsp; For example, you say you only want rows that start with REJECTED in the STATUS variable text.&amp;nbsp; If STATUS includes the phrase "was not rejected",&amp;nbsp; the CONTAINS operator would select that observation.&amp;nbsp; There are simpler ways of concatentating a % sign onto your macro variable value, but I'm&amp;nbsp; assuming you chose the data step for your own good reasons. So give this code sample a whirl: &lt;/P&gt;&lt;PRE&gt;&amp;nbsp; /* Make a data set to play with */
data de_services_statistics;
&amp;nbsp;&amp;nbsp; infile datalines dlm='*';
&amp;nbsp;&amp;nbsp; input ID Status $35.;
datalines;
1*Don't choose me.
2*REJECTED - pick me!
3*I'm not rejected.
;
run;

&amp;nbsp; /* Test the code */
%let de_status=REJECTED;
data _NULL_;
&amp;nbsp;&amp;nbsp; /* SYMGET retrieves macro variable values at execution time */
&amp;nbsp;&amp;nbsp; /* The CAT series of functions make text manipulation easier than with the */
&amp;nbsp;&amp;nbsp; /* concatenation operators (|| or !!) */
&amp;nbsp;&amp;nbsp; whereclausesummary = CAT("upcase(status) LIKE '",cats(symget('de_status'),"%'"));
&amp;nbsp;&amp;nbsp; /* SYMPUTX is a newer version of SYMPUT with extra features */
&amp;nbsp;&amp;nbsp; call symputx("whereclausesummary",whereclausesummary);
run;

proc sql; 
select * from de_services_statistics
&amp;nbsp;&amp;nbsp; where &amp;amp;whereclausesummary
;
quit;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Nov 2011 16:19:26 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2011-11-01T16:19:26Z</dc:date>
    <item>
      <title>Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38920#M7869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have a parameter for my stored process where one of the values the user can select is 'REJECTED', If the user selects 'REJECTED', I want to select all the records that begin with the word 'REJECTED', is there anything in SAS, which will let me check if the value begins with a certain word like 'REJECTED'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Shri &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 20:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38920#M7869</guid>
      <dc:creator>sks</dc:creator>
      <dc:date>2011-10-31T20:39:19Z</dc:date>
    </item>
    <item>
      <title>Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38921#M7870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The answer is yes, but which function or operator to use would depend upon how you want to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g., if upcase(variable) =: "REJECTED"&lt;/P&gt;&lt;P&gt;would limit the records to those records where a variable named variable contained a value that at least started with the string rejected, regardless of case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 20:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38921#M7870</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-31T20:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38922#M7871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could potentially use the LIKE operator in PROC SQL. For example, the following snippet would give you all rows where the subsetting variable begins with 'rejected'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;﻿... where upcase(variable) like 'REJECTED%'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 10:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38922#M7871</guid>
      <dc:creator>TomCook</dc:creator>
      <dc:date>2011-11-01T10:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38923#M7872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you for your response, my first choice was to use LIKE too, but the problem is the macro contains the word 'REJECTED' and if I have to use it with Like as you have mentioned, I have to add % symbol at the end of the word Rejected. which I did not know how to do. So for now I have used Contains &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let de_status=REJECTED&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;destatus = cats(&amp;amp;de_status,"%");&lt;/P&gt;&lt;P&gt;put destatus;&lt;/P&gt;&lt;P&gt;call symput("destat"," ' " || destatus || " ' ");&lt;/P&gt;&lt;P&gt;whereclausesummary = "upcase(status) contains &amp;amp;destat")&lt;/P&gt;&lt;P&gt;call symput ("whereclausesummary",whereclausesummary);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from de_services_statistics&lt;/P&gt;&lt;P&gt;where &amp;amp;whereclausesummary&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 14:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38923#M7872</guid>
      <dc:creator>sks</dc:creator>
      <dc:date>2011-11-01T14:14:10Z</dc:date>
    </item>
    <item>
      <title>Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38924#M7873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sks,&lt;/P&gt;&lt;P&gt;There is a possible problem with using CONTAINS.&amp;nbsp; For example, you say you only want rows that start with REJECTED in the STATUS variable text.&amp;nbsp; If STATUS includes the phrase "was not rejected",&amp;nbsp; the CONTAINS operator would select that observation.&amp;nbsp; There are simpler ways of concatentating a % sign onto your macro variable value, but I'm&amp;nbsp; assuming you chose the data step for your own good reasons. So give this code sample a whirl: &lt;/P&gt;&lt;PRE&gt;&amp;nbsp; /* Make a data set to play with */
data de_services_statistics;
&amp;nbsp;&amp;nbsp; infile datalines dlm='*';
&amp;nbsp;&amp;nbsp; input ID Status $35.;
datalines;
1*Don't choose me.
2*REJECTED - pick me!
3*I'm not rejected.
;
run;

&amp;nbsp; /* Test the code */
%let de_status=REJECTED;
data _NULL_;
&amp;nbsp;&amp;nbsp; /* SYMGET retrieves macro variable values at execution time */
&amp;nbsp;&amp;nbsp; /* The CAT series of functions make text manipulation easier than with the */
&amp;nbsp;&amp;nbsp; /* concatenation operators (|| or !!) */
&amp;nbsp;&amp;nbsp; whereclausesummary = CAT("upcase(status) LIKE '",cats(symget('de_status'),"%'"));
&amp;nbsp;&amp;nbsp; /* SYMPUTX is a newer version of SYMPUT with extra features */
&amp;nbsp;&amp;nbsp; call symputx("whereclausesummary",whereclausesummary);
run;

proc sql; 
select * from de_services_statistics
&amp;nbsp;&amp;nbsp; where &amp;amp;whereclausesummary
;
quit;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 16:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38924#M7873</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-11-01T16:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Macro Output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38925#M7874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no need to have a data step. The following SQL will do the job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from de_services_statistics &lt;/P&gt;&lt;P&gt; where upcase(status) like upcase("&amp;amp;de_status.%")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Nov 2011 08:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Macro-Output/m-p/38925#M7874</guid>
      <dc:creator>vpn_das</dc:creator>
      <dc:date>2011-11-22T08:18:56Z</dc:date>
    </item>
  </channel>
</rss>

