<?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: Flag and store observation based on condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567417#M11506</link>
    <description>&lt;P&gt;Thank you for the feedback.&lt;/P&gt;&lt;P&gt;Avoiding the macro is definitely an option.&lt;/P&gt;&lt;P&gt;The following code would simply put another column with then names of constituents where the condition (less than or equal to 5) is met:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.want&lt;BR /&gt;set work.have;&lt;BR /&gt;if PrimaryResultsCount le 5 then Warning=Constituent_Name;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The column variable, Warning, may be full of blanks.&amp;nbsp; If not, I would like to create a macro variable that will tell the user that there are constituents that do not meet the condition somewhere within the data.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2019 19:08:34 GMT</pubDate>
    <dc:creator>jawhitmire</dc:creator>
    <dc:date>2019-06-19T19:08:34Z</dc:date>
    <item>
      <title>Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567387#M11496</link>
      <description>&lt;P&gt;SAS Version 9.4&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.eqn32;
	input DFLAW_Activity_Analyte 9.8 @13 Constituent_Name $20. @29 ResultsCount 
		@32 PrimaryResultsCount ;
	datalines;
0.0000001	American		8	6
0.0003333	American		0	1
0.0275245	Ceiling			7	6
0.0000011	Baltimore		7	6
0.0444444	Curry			5	4
0.0055555	Canary			8	6
0.0000026	Europe			7	6
0.0055552	Neptune			7	6
0.0001111	Platonic		8	6
0.0000001	Playtown		8	6
0.0002222	Pluto			8	6
0.0033322	Plumbing		12	10
0.0001146	Stronghold		8	6
0.0000188	Tigerland		8	6
0.0000112	Unbrella		7	6
0.0007777	Underwear		7	6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If PrimaryResultsCount is less than 6 (happens where Constituent_Name is either&amp;nbsp;American and Curry), I need to create a macro 'flag' that&amp;nbsp;may be used later to&amp;nbsp;warn the user.&amp;nbsp;&amp;nbsp;I'd also like to retain&amp;nbsp;the corresponding Constituent_Names that do not meet the condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far - but it's not working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.want;
	set work.eqn32 end=eof;
	N+1;
   array char[*] _character_;
   array c_count[100] _temporary_ (100*0);
   if PrimaryResultscount le 5 then warning=constituent_name;
   do i = 1 to dim(char);
      if missing(char[i]) then c_count[i] + 1;
   end;
   if eof then do;
      do i = 1 to dim(char);
         Variable = vname(char[i]);
         NMiss = c_count[i];
		 NHave=N-NMiss;
		  if NHave ne N then call symputx('Flag',"Missing Data");
		  	else call symputx('Flag',"Complete Data");
         output;
      end;
   end;
keep Variable N NMiss NHave  ;
run;
%put &amp;amp;Flag;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you for the support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 18:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567387#M11496</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-19T18:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567410#M11504</link>
      <description>What do you want as the output? How many macro variables? What output exactly? &lt;BR /&gt;&lt;BR /&gt;I'm not sure macro variables are the best option, since you'll have multiple that match the condition so keeping them straight will be a pain.</description>
      <pubDate>Wed, 19 Jun 2019 18:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567410#M11504</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-19T18:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567417#M11506</link>
      <description>&lt;P&gt;Thank you for the feedback.&lt;/P&gt;&lt;P&gt;Avoiding the macro is definitely an option.&lt;/P&gt;&lt;P&gt;The following code would simply put another column with then names of constituents where the condition (less than or equal to 5) is met:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.want&lt;BR /&gt;set work.have;&lt;BR /&gt;if PrimaryResultsCount le 5 then Warning=Constituent_Name;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The column variable, Warning, may be full of blanks.&amp;nbsp; If not, I would like to create a macro variable that will tell the user that there are constituents that do not meet the condition somewhere within the data.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567417#M11506</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-19T19:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567421#M11508</link>
      <description>&lt;P&gt;What about an overall flag in addition to your warning then?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.want
set work.have END=EOF;
retain flag 0;
if PrimaryResultsCount le 5 then do;
Warning=Constituent_Name;
flag=1;
end;

*creates macro variable;
If EOF then call symputx('resultsCheck', 'Failed');
run;

%put ResultsCheck = &amp;amp;resultsCheck;

%if &amp;amp;resultsCheck = Failed %then %do;
     %PUT WARNING:  XYX has errors;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/248885"&gt;@jawhitmire&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for the feedback.&lt;/P&gt;
&lt;P&gt;Avoiding the macro is definitely an option.&lt;/P&gt;
&lt;P&gt;The following code would simply put another column with then names of constituents where the condition (less than or equal to 5) is met:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.want&lt;BR /&gt;set work.have;&lt;BR /&gt;if PrimaryResultsCount le 5 then Warning=Constituent_Name;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The column variable, Warning, may be full of blanks.&amp;nbsp; If not, I would like to create a macro variable that will tell the user that there are constituents that do not meet the condition somewhere within the data.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567421#M11508</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-19T19:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567423#M11509</link>
      <description>data work.want;&lt;BR /&gt;set work.have end=eof;&lt;BR /&gt;retain flag 0;&lt;BR /&gt;if PrimaryResultsCount le 5 then do;&lt;BR /&gt;Warning=Constituent_Name;&lt;BR /&gt;flag=1;&lt;BR /&gt;end;&lt;BR /&gt;if eof and flag=1 then call symputx('resultscheck','failed');&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;The problem here is that a call to &amp;amp;resultscheck will fail when Warning is a column full of blanks (ie... none of the data met the condition of less than or equal to 5)</description>
      <pubDate>Wed, 19 Jun 2019 19:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567423#M11509</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-19T19:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567424#M11510</link>
      <description>&lt;P&gt;Add an else then?&lt;BR /&gt;&lt;BR /&gt;else call symputx('resultscheck', 'passed');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: note that these comparisons are case sensitive, Failed is not the same as failed.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 19:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567424#M11510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-19T19:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Flag and store observation based on condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567442#M11514</link>
      <description>Thank you. It works perfectly.&lt;BR /&gt;Cheers!</description>
      <pubDate>Wed, 19 Jun 2019 20:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Flag-and-store-observation-based-on-condition/m-p/567442#M11514</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-19T20:06:16Z</dc:date>
    </item>
  </channel>
</rss>

