<?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: Macro for QA in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786873#M251285</link>
    <description>You need to add a conditional macro statement. If you have any it basically means you don't need to check the field except for missing. Honestly not sure how this requirement would overlap with your current data step shown.</description>
    <pubDate>Mon, 20 Dec 2021 23:39:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-12-20T23:39:02Z</dc:date>
    <item>
      <title>Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786855#M251274</link>
      <description>I am checking if in my dataset the logic for assigning a particular stage is correct or not by reading in the reference sheet. In the reference sheet for certain variable the value is any( which means any value is valid if non missing). Now when I compare the two in my macro, SAS thinks any is a value and searches for the string ‘any’. How do I make SAS understand the when ‘any’ in a variable, then include all non missing values for that field as valid?</description>
      <pubDate>Mon, 20 Dec 2021 22:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786855#M251274</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-20T22:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786858#M251276</link>
      <description>&lt;P&gt;Please post your code.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 22:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786858#M251276</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-20T22:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786868#M251283</link>
      <description>Excel sheet snap:&lt;BR /&gt;Schema t N m stage&lt;BR /&gt;00050 T0 N1 m0 1&lt;BR /&gt;00050 T0 N2 M0 2&lt;BR /&gt;00050 T0 Any N M1 3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SAS macro:&lt;BR /&gt;Data _null_;&lt;BR /&gt;Set one;&lt;BR /&gt;If (schema_id in (&amp;amp;schemaid.) and clin_t in (‘&amp;amp;t’) and clin_n in (‘&amp;amp;n’) and clin_m in (‘&amp;amp;m’) and clin_stage in (‘&amp;amp;stage’)&lt;BR /&gt;then do;&lt;BR /&gt;Flag=1;&lt;BR /&gt;End;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Dec 2021 23:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786868#M251283</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-20T23:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786873#M251285</link>
      <description>You need to add a conditional macro statement. If you have any it basically means you don't need to check the field except for missing. Honestly not sure how this requirement would overlap with your current data step shown.</description>
      <pubDate>Mon, 20 Dec 2021 23:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786873#M251285</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-20T23:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786876#M251287</link>
      <description>&lt;P&gt;What does EXCEL have to do with this. Are you saying you have a SAS dataset (perhaps created by converting a sheet in an XLSX file?) that have data like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data conditions;
   length schema $32 clin_t $8 clin_n $8 clin_m $8 clin_stage $8 ;
   input Schema--clin_stage ;
cards;  
00050 T0 N1  m0 1
00050 T0 N2  M0 2
00050 T0 Any M1 3
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And what does SAS macro language have to do with this?&lt;/P&gt;
&lt;P&gt;Are you saying you want to use the data in the CONDITIONS dataset to generate code?&lt;/P&gt;
&lt;P&gt;It is much easier to generate code from data using a data step than the macro language.&lt;/P&gt;
&lt;P&gt;What code do you want to generate?&lt;/P&gt;
&lt;P&gt;Perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set conditions ;
  file code ;
  if _n_ &amp;gt; 1 then put 'else ' @ ;
  put 'if ' schema = :$quote. @;
  if upcase(clin_t) ne 'ANY' then put 'and ' clin_t =:$quote. @;
  if upcase(clin_n) ne 'ANY' then put 'and ' clin_n =:$quote. @;
  if upcase(clin_m) ne 'ANY' then put 'and ' clin_m =:$quote. @;
  put 'and ' clin_stage =:$quote. 'then flag=1;' ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if schema="00050" and clin_t="T0" and clin_n="N1" and clin_m="m0" and clin_stage="1" then flag=1;
else if schema="00050" and clin_t="T0" and clin_n="N2" and clin_m="M0" and clin_stage="2" then flag=1;
else if schema="00050" and clin_t="T0" and clin_m="M1" and clin_stage="3" then flag=1;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you could then use in a data step that reads in the actual data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
%include code / source2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Dec 2021 00:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786876#M251287</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-21T00:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786883#M251289</link>
      <description>&lt;P&gt;I had lately to deal with a very similar use case. Below what worked for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input (schema_id clin_t clin_n clin_m clin_stage) ($);
  datalines;
00050 T0 N1 m0 1
00050 T0 N2 M0 2
00050 T0 XX N M1 3
00050 T0 N9 M0 2
;

data want;
  if _n_=1 then
    do;
      if 0 then set have lookup;
      dcl hash h1(dataset:'lookup', hashexp:5);
      h1.defineKey('Schema', 't', 'N', 'm', 'stage');
      h1.defineData('schema');
      h1.defineDone();
      drop Schema t N m stage;
    end;
  call missing(of _all_);

  set have;
 
  if cmiss(schema_id, clin_t, clin_n, clin_m, clin_stage) ne 0 then; /* some exception handling */

  flag= h1.check(key:schema_id, key:clin_t, key:clin_n, key:clin_m, key:clin_stage) = 0;
  if flag ne 1 then flag= h1.check(key:schema_id, key:clin_t, key:'ANY', key:clin_m, key:clin_stage) = 0;

  /** alternative syntax **/
  /**
  flag= 
    h1.check(key:schema_id, key:clin_t, key:clin_n, key:clin_m, key:clin_stage) = 0
    or
    h1.check(key:schema_id, key:clin_t, key:'ANY', key:clin_m, key:clin_stage) = 0
    ;
  **/
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1640055496231.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66910iC968747E701ABE3D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1640055496231.png" alt="Patrick_0-1640055496231.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 03:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786883#M251289</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-12-21T03:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786891#M251297</link>
      <description>Thank you for the comments..&lt;BR /&gt;So, the reference sheet is huge with lots of schema and various conditions for each schema which are dynamic. So, I am using an excel sheet and reading it as macro so that when the value changes, I just have to update the excel.</description>
      <pubDate>Tue, 21 Dec 2021 06:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786891#M251297</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-21T06:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786892#M251298</link>
      <description>I agree.. and that what I am struggling with. I tried putting a condition&lt;BR /&gt;If &amp;amp;t = anyT the &amp;amp;t ne .&lt;BR /&gt;But it doesn’t work..</description>
      <pubDate>Tue, 21 Dec 2021 06:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786892#M251298</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-21T06:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786893#M251299</link>
      <description>I was wondering if something like * instead of any would make SAS take it as any value? I tried * and ** but doesn’t work..&lt;BR /&gt;I am thinking if something on that line though would read directly from excel to SAS as Any</description>
      <pubDate>Tue, 21 Dec 2021 06:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786893#M251299</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-21T06:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786904#M251307</link>
      <description>&lt;P&gt;Your curly single quotes will cause a syntax error. And single quotes prevent the resolution of macro triggers anyway.&lt;/P&gt;
&lt;P&gt;Further, you don't need the IN operator when you compare with single values only.&lt;/P&gt;
&lt;P&gt;This is how you make code conditional:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set one;
flag =
  schema_id in (&amp;amp;schemaid.)
  and clin_t eq "&amp;amp;t"
  %if %upcase(&amp;amp;n) ne ANY
  %then %do;
  and clin_n eq "&amp;amp;n"
  %end;
  and clin_m eq "&amp;amp;m"
  and clin_stage eq "&amp;amp;stage"
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;flag will either be 0 (false) or 1 (true).&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 09:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786904#M251307</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-21T09:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786909#M251311</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410561"&gt;@VD17&lt;/a&gt;&amp;nbsp;Not sure why you need a macro at all. The approach I've provided earlier will work and is easily expandable should you also have "any" for other columns.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 10:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/786909#M251311</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-12-21T10:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787150#M251448</link>
      <description>There are two files in play here.&lt;BR /&gt;One is the reference document which is dynamic and will change with time. This document basically says is t is T0, N is N1 and M is M0 then stage should be 1 for schema ID 00040 and so on. So, it has atleast 1500 rows.&lt;BR /&gt;Second is the dataset (SAS dataset) which I want to QA is the stage is correct according to the reference table.&lt;BR /&gt;To do so, I read in the excel in SAS to compare with file two (SAS dataset).&lt;BR /&gt;For this I am using a macro (I am open to other methods), so that if the condition changes then I just have to update the excel and the program remains the same.&lt;BR /&gt;The excel can have AnyT, AnyN, AnyM for certain conditions. When I compare with the SAS file, SAS looks for AnyT in the dataset instead of all the valid non missing values of T and returns an error. This is what I want to fix</description>
      <pubDate>Wed, 22 Dec 2021 18:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787150#M251448</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-22T18:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787154#M251452</link>
      <description>Please provide small examples of each file and the program used to convert those conditions to SAS code. &lt;BR /&gt;&lt;BR /&gt;You'll need to add macro logic to handle the Any values. Seems like you're manually building a data validation system (there are tools that do this) but if you search on lexjansen.com for data validation you should find examples as well. &lt;BR /&gt;</description>
      <pubDate>Wed, 22 Dec 2021 18:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787154#M251452</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-22T18:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787165#M251456</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410561"&gt;@VD17&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you for the comments..&lt;BR /&gt;So, the reference sheet is huge with lots of schema and various conditions for each schema which are dynamic. So, I am using an excel sheet and reading it as macro so that when the value changes, I just have to update the excel.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It sounds like your code generation needs are extensive.&amp;nbsp; It will probably be a lot easier to generate the code using SAS code instead of macro code.&amp;nbsp; You will not need to move the reference data into macro variables.&amp;nbsp; You can more naturally test for things like the ANY criteria you mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get better example code provide a clearer picture of what you are doing.&amp;nbsp; What are you checking for?&amp;nbsp; &amp;nbsp;How have decided to store the reference data to describe those checks?&amp;nbsp;What do you think is the code you need to generate to make those checks?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 20:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787165#M251456</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-22T20:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787178#M251462</link>
      <description>&lt;P&gt;%macro tnmsgcp;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;IF 0 THEN SET Master_SG_cp NOBS=X;&lt;BR /&gt;CALL SYMPUT('RECCOUNT',X);&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%DO i=1 %TO &amp;amp;reccount;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_; set Master_SG_CP (obs=&amp;amp;i.);&lt;BR /&gt;call symput("SchemaId",schemaId);&lt;BR /&gt;call symput("t_value",t_value);&lt;BR /&gt;call symput("n_value",n_value);&lt;BR /&gt;call symput("m_value",m_value);&lt;BR /&gt;call symput("stage_group",stage_group);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%if &amp;amp;t_value. ne "Any" and &amp;amp;n_value. ne "Any" and &amp;amp;m_value. ne "Any"&lt;BR /&gt;%then %do;&lt;BR /&gt;data one;&lt;/P&gt;&lt;P&gt;set STEP1B_TNMedits ;&lt;/P&gt;&lt;P&gt;if (schema_id eq (&amp;amp;SchemaId.) and clin_t eq ("&amp;amp;t_value") and clin_n eq ("&amp;amp;n_value")&lt;BR /&gt;and clin_m in ("&amp;amp;m_value")and clin_stage NOT in ("&amp;amp;stage_group") )&lt;BR /&gt;then do;&lt;BR /&gt;tnm_edit2000=1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%end;&lt;BR /&gt;%mend tnmsgcp;&lt;/P&gt;&lt;P&gt;%tnmsgcp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use this logic now, and its gives me an error&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;ERROR: Required operator not found in expression: &amp;amp;t_value. ne "Any" and &amp;amp;n_value. ne "Any" and &amp;amp;m_value. ne "Any"&lt;/DIV&gt;&lt;DIV class=""&gt;ERROR: The macro TNMSGCP will stop executing.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Not sure what am I doing wrong.&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Dec 2021 23:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787178#M251462</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-22T23:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787180#M251463</link>
      <description>Post your full log and example data would really help.</description>
      <pubDate>Wed, 22 Dec 2021 23:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787180#M251463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-22T23:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787188#M251467</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410561"&gt;@VD17&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides of the syntax error this macro logic attempts for&amp;nbsp; every single row in table&amp;nbsp;&lt;SPAN&gt;Master_SG_cp to execute the data step creating table One.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For each row there will be a full pass through source table&amp;nbsp;STEP1B_TNMedits and each iteration will replace target table One. The resulting table One will be from the very last iteration. ....looks to me like you have to rethink the design of your macro/program logic.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 01:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787188#M251467</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-12-23T01:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787189#M251468</link>
      <description>&lt;P&gt;First you need to know what SAS code you want to generate.&lt;/P&gt;
&lt;P&gt;It looks like you are trying to generate code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  set STEP1B_TNMedits ;
  if (schema_id eq (&amp;amp;SchemaId.)
     and clin_t eq ("&amp;amp;t_value")
     and clin_n eq ("&amp;amp;n_value")
     and clin_m in ("&amp;amp;m_value")
     and clin_stage NOT in ("&amp;amp;stage_group") 
     ) then do;
    tnm_edit2000=1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which raises a number of questions.&lt;/P&gt;
&lt;P&gt;What is the source of the&amp;nbsp;STEP1B_TNMedits dataset? Does it have the variables you mention in the IF statement?&amp;nbsp; Are they defined as the data types implied by how they are used in IF statement?&amp;nbsp; Is SCHEMA_ID numeric? If so then why did the values in your first post include leading zeros?&amp;nbsp; That would imply that SCHEMA_ID is a character string that consists of digits.&amp;nbsp; Are all of the other variables character strings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you use EQ operator for some of the variables and IN operator for the others?&amp;nbsp; Are you expecting those others to have a list of values in the&amp;nbsp;Master_SG_CP source dataset?&amp;nbsp; If so you are not generating code that could handle that.&lt;/P&gt;
&lt;P&gt;Why are recreating the same output dataset ONE over and over again? At the end of the %DO loop only the result from the last version of those many data steps will exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also don't seem to be accounting for many things that look to me should be parameters to such a macro.&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The name of the dataset with the parameters you want to use to create your QA findings.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;The name of the dataset with the actual data that is to be checked.&lt;/LI&gt;
&lt;LI&gt;The name of the dataset (or datasets) to be generated with the results of the QA checks.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 01:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787189#M251468</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-23T01:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787701#M251739</link>
      <description>&lt;P&gt;I am trying this:&lt;/P&gt;&lt;P&gt;%macro tnmsgcp;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;BR /&gt;IF 0 THEN SET Master_SG_cp NOBS=X;&lt;BR /&gt;CALL SYMPUT('RECCOUNT',X);&lt;BR /&gt;STOP;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%DO i=1 %TO &amp;amp;reccount;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_; set Master_SG_CP (obs=&amp;amp;i.);&lt;BR /&gt;call symput("SchemaId",schemaId);&lt;BR /&gt;call symput("t_value",t_value);&lt;BR /&gt;call symput("n_value",n_value);&lt;BR /&gt;call symput("m_value",m_value);&lt;BR /&gt;call symput("stage_group",stage_group);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Invalid_Clinical_SG_&amp;amp;i Invalid_Path_SG_&amp;amp;i Invalid_PT_SG_&amp;amp;i;&lt;BR /&gt;set STEP1B_TNMedits ;&lt;BR /&gt;if ("&amp;amp;t_value") ne "Any T" then ("&amp;amp;t_value") in "%T%"; else ("&amp;amp;t_value") in ("&amp;amp;t_value");&lt;BR /&gt;if ("&amp;amp;n_value") ne "Any N" then ("&amp;amp;n_value") in "%N%"; else ("&amp;amp;n_value") in ("&amp;amp;n_value");&lt;BR /&gt;if ("&amp;amp;m_value") ne "Any M" then ("&amp;amp;m_value") in "%M%"; else ("&amp;amp;m_value") in ("&amp;amp;m_value");&lt;BR /&gt;&lt;BR /&gt;if (schema_id in (&amp;amp;SchemaId.) and clin_t in ("&amp;amp;t_value") and clin_n in ("&amp;amp;n_value")&lt;BR /&gt;and clin_m in ("&amp;amp;m_value")and clin_stage NOT in ("&amp;amp;stage_group") )&lt;BR /&gt;then do;&lt;BR /&gt;tnm_edit2000=1;&lt;BR /&gt;output Invalid_Clinical_SG_&amp;amp;i;&lt;BR /&gt;end;&lt;BR /&gt;if (schema_id in (&amp;amp;SchemaId.) and path_t in ("&amp;amp;t_value") and path_n in ("&amp;amp;n_value") and&lt;BR /&gt;path_m in ("&amp;amp;m_value") and path_stage NOT in ("&amp;amp;stage_group") )&lt;BR /&gt;then do;&lt;BR /&gt;tnm_edit2000=1;&lt;BR /&gt;output Invalid_Path_SG_&amp;amp;i;&lt;BR /&gt;end;&lt;BR /&gt;if (schema_id in (&amp;amp;SchemaId.) and post_t in ("&amp;amp;t_value") and post_n in ("&amp;amp;n_value") and&lt;BR /&gt;post_m in ("&amp;amp;m_value") and post_stage NOT in ("&amp;amp;stage_group") )&lt;BR /&gt;then do;&lt;BR /&gt;tnm_edit2000=1;&lt;BR /&gt;output Invalid_PT_SG_&amp;amp;i;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend tnmsgcp;&lt;/P&gt;&lt;P&gt;%tnmsgcp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still it gives me error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck. What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 00:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787701#M251739</guid>
      <dc:creator>VD17</dc:creator>
      <dc:date>2021-12-30T00:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for QA</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787706#M251742</link>
      <description>&lt;P&gt;Before trying to use macro code to generate SAS code make sure you have working SAS code.&lt;/P&gt;
&lt;P&gt;No matter what values the macro variables have this is not valid SAS syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ("&amp;amp;t_value") ne "Any T" then ("&amp;amp;t_value") in "%T%"; 
else ("&amp;amp;t_value") in ("&amp;amp;t_value");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What goes after the THEN or the ELSE has to be a valid SAS statement.&amp;nbsp; Not some boolean expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your boolean expression also don't make any sense.&amp;nbsp; Why use IN to compare a single value to another single value? Use simple equality operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you mean to call a macro named T?&amp;nbsp; Did you even create such a macro?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 04:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-QA/m-p/787706#M251742</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-30T04:28:53Z</dc:date>
    </item>
  </channel>
</rss>

