<?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 do I select a customer with a pattern in Score using Macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478338#M123365</link>
    <description>&lt;P&gt;If you want a table .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set feedback;
 if customer=lag(customer) and score=. and lag(score)=5 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 12:08:32 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-07-16T12:08:32Z</dc:date>
    <item>
      <title>How do I select a customer with a pattern in Score using Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478186#M123278</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need&amp;nbsp;find out which CUSTOMER has given a "5" score immediately followed by a missing score (among the data shown above, it is C).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Q10;
data feedback;
infile datalines missover;
input Customer $
	  Score 
	  Comment $30. ;
datalines;
A	3	The is no parking
A	5	The food is expensive
B	.	I like the food
C	5	It tastes good
C	.	 
C	3	I like the drink
D	4	The dessert is tasty
D	2	I don't like the services
;
run;
proc print data = feedback;
run;

proc sql;
select count(distinct Customer) into :n from feedback;
select distinct Customer into :cust1 - from feedback;
run;

%macro main();
%do i=1 %to &amp;amp;n.;
 data feedback_&amp;amp;&amp;amp;cust&amp;amp;i; set feedback;
 where Customer = "&amp;amp;&amp;amp;cust&amp;amp;i";
run;
%feedback_mn(cust=&amp;amp;&amp;amp;cust&amp;amp;i);
%end;
%mend;

%macro feedback_mn(cust=);
	data have;
	set feedback;
	where Customer = "&amp;amp;&amp;amp;cust&amp;amp;i";
 %if %length(Score)= 0 and lag1(Score) = 5 %then output;
 run;

 proc print data  = have;
 run;
%mend;
	
%main();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is highly appreciated. please check the code, I am getting this error,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A character operand was found in the %EVAL function or %IF condition where a numeric operand&lt;BR /&gt;is required. The condition was: %length(Score)= 0 and lag1(Score) = 5&lt;BR /&gt;ERROR: The macro FEEDBACK_MN will stop executing.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 09:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478186#M123278</guid>
      <dc:creator>arunvaibhav21</dc:creator>
      <dc:date>2018-07-15T09:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I select a customer with a pattern in Score using Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478192#M123283</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data feedback;
infile datalines missover;
input Customer $
	  Score 
	  Comment $30. ;
datalines;
A	3	The is no parking
A	5	The food is expensive
B	.	I like the food
C	5	It tastes good
C	.	 
C	3	I like the drink
D	4	The dessert is tasty
D	2	I don't like the services
;
run;
data _null_;
 set feedback;
 if customer=lag(customer) and score=. and lag(score)=5 then put (_all_) (:);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Jul 2018 11:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478192#M123283</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-15T11:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I select a customer with a pattern in Score using Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478221#M123295</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the answer. But I dont see the output?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jul 2018 18:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478221#M123295</guid>
      <dc:creator>arunvaibhav21</dc:creator>
      <dc:date>2018-07-15T18:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I select a customer with a pattern in Score using Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478338#M123365</link>
      <description>&lt;P&gt;If you want a table .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set feedback;
 if customer=lag(customer) and score=. and lag(score)=5 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 12:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-select-a-customer-with-a-pattern-in-Score-using-Macro/m-p/478338#M123365</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-16T12:08:32Z</dc:date>
    </item>
  </channel>
</rss>

