<?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 Macro out putting only first call in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561250#M157085</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get a macro call to output each new set of conditions in a datastep (not sure if im explaining that right!), but it's outing observations meeting the first condition.&amp;nbsp; I think it has something to do with where I'm calling the macro or macro can't override another...I have no idea. So right now, I only get 4 observations meeting the first conditons (the 'PRE').&amp;nbsp; &amp;nbsp;Here is my code, would appreciate any help!&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 %macro zg (t, zgvar, stat,test, cd, orres, unit);

  	if LBJTPT&amp;amp;t ^='' and &amp;amp;zgvar ^='' then do;
	
	  zgtpt=strip(LBJTPT&amp;amp;t);
	  zgtptnum=&amp;amp;t;

	  LBJPHc= strip(put(LBJPH&amp;amp;t,best.));
	  LBJTEMPc=strip(put(LBJTEMP&amp;amp;t,best.));

	  zgstat=&amp;amp;stat;
	  zgtest= &amp;amp;test;
	  zgtestcd=&amp;amp;cd;
	  zgorres= &amp;amp;orres;
	  zgorresu= &amp;amp;unit;
	  if lbjdat ^=. then ZGDTC=put(lbjdat, is8601da.);
	  output;
	  end; 
	  %mend zg;

data tpt1;
length usubjid $19 zgtest zgtestcd zgorres zgtpt zgstat zgtpt $100 zgdtc zgorresu $50 ;
set db.lbj (where=(lbjperf_display='Yes' and formname ^= 'BLANK'));

  if not missing(subject) then usubjid = 'PVP101-01-' || Strip(subject);

  	%zg (1,LBJND1_DISPLAY, 'NOT DONE', 'Not Done Pre', 'ZGPRE', '','' );
	%zg (1,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (1,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU1_DISPLAY);

keep usubjid zgtest zgtestcd zgorres zgtpt zgstat zgtpt zgdtc zgorresu zgtptnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;And to REAAALLLY help me out,&amp;nbsp; &amp;nbsp;I trying to figure out how to loop this macro to output as each timepoint 't' changes&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 %macro zg (t, zgvar, stat,test, cd, orres, unit);

  	if LBJTPT&amp;amp;t ^='' and &amp;amp;zgvar ^='' then do;
	
	  zgtpt=strip(LBJTPT&amp;amp;t);
	  zgtptnum=&amp;amp;t;

	  LBJPHc= strip(put(LBJPH&amp;amp;t,best.));
	  LBJTEMPc=strip(put(LBJTEMP&amp;amp;t,best.));

	  zgstat=&amp;amp;stat;
	  zgtest= &amp;amp;test;
	  zgtestcd=&amp;amp;cd;
	  zgorres= &amp;amp;orres;
	  zgorresu= &amp;amp;unit;
	  if lbjdat ^=. then ZGDTC=put(lbjdat, is8601da.);
	  output;
	  end; 
	  %mend zg;

data tpt1;
length usubjid $19 zgtest zgtestcd zgorres zgtpt zgstat zgtpt $100 zgdtc zgorresu $50 ;
set db.lbj (where=(lbjperf_display='Yes' and formname ^= 'BLANK'));

  if not missing(subject) then usubjid = 'PVP101-01-' || Strip(subject);

  	%zg (1,LBJND1_DISPLAY, 'NOT DONE', 'Not Done Pre', 'ZGPRE', '','' );
	%zg (1,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (1,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU1_DISPLAY);

keep usubjid zgtest zgtestcd zgorres zgtpt zgstat zgtpt zgdtc zgorresu zgtptnum;
run;



/***NEED TO GET THESE TO OUTPUT WITH EACH TIMEPOINT CHANGE***/




	%zg (2,LBJND2_DISPLAY, 'NOT DONE', 'Not Done Post 15', 'ZGPOST15', '','' );
	%zg (2,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (2,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU2_DISPLAY);

	%zg (3,LBJND3_DISPLAY, 'NOT DONE', 'Not Done Post 20', 'ZGPOST20', '','' );
	%zg (3,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (3,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU3_DISPLAY);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2019 22:00:08 GMT</pubDate>
    <dc:creator>jenim514</dc:creator>
    <dc:date>2019-05-23T22:00:08Z</dc:date>
    <item>
      <title>Macro out putting only first call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561250#M157085</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get a macro call to output each new set of conditions in a datastep (not sure if im explaining that right!), but it's outing observations meeting the first condition.&amp;nbsp; I think it has something to do with where I'm calling the macro or macro can't override another...I have no idea. So right now, I only get 4 observations meeting the first conditons (the 'PRE').&amp;nbsp; &amp;nbsp;Here is my code, would appreciate any help!&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 %macro zg (t, zgvar, stat,test, cd, orres, unit);

  	if LBJTPT&amp;amp;t ^='' and &amp;amp;zgvar ^='' then do;
	
	  zgtpt=strip(LBJTPT&amp;amp;t);
	  zgtptnum=&amp;amp;t;

	  LBJPHc= strip(put(LBJPH&amp;amp;t,best.));
	  LBJTEMPc=strip(put(LBJTEMP&amp;amp;t,best.));

	  zgstat=&amp;amp;stat;
	  zgtest= &amp;amp;test;
	  zgtestcd=&amp;amp;cd;
	  zgorres= &amp;amp;orres;
	  zgorresu= &amp;amp;unit;
	  if lbjdat ^=. then ZGDTC=put(lbjdat, is8601da.);
	  output;
	  end; 
	  %mend zg;

data tpt1;
length usubjid $19 zgtest zgtestcd zgorres zgtpt zgstat zgtpt $100 zgdtc zgorresu $50 ;
set db.lbj (where=(lbjperf_display='Yes' and formname ^= 'BLANK'));

  if not missing(subject) then usubjid = 'PVP101-01-' || Strip(subject);

  	%zg (1,LBJND1_DISPLAY, 'NOT DONE', 'Not Done Pre', 'ZGPRE', '','' );
	%zg (1,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (1,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU1_DISPLAY);

keep usubjid zgtest zgtestcd zgorres zgtpt zgstat zgtpt zgdtc zgorresu zgtptnum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;And to REAAALLLY help me out,&amp;nbsp; &amp;nbsp;I trying to figure out how to loop this macro to output as each timepoint 't' changes&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 %macro zg (t, zgvar, stat,test, cd, orres, unit);

  	if LBJTPT&amp;amp;t ^='' and &amp;amp;zgvar ^='' then do;
	
	  zgtpt=strip(LBJTPT&amp;amp;t);
	  zgtptnum=&amp;amp;t;

	  LBJPHc= strip(put(LBJPH&amp;amp;t,best.));
	  LBJTEMPc=strip(put(LBJTEMP&amp;amp;t,best.));

	  zgstat=&amp;amp;stat;
	  zgtest= &amp;amp;test;
	  zgtestcd=&amp;amp;cd;
	  zgorres= &amp;amp;orres;
	  zgorresu= &amp;amp;unit;
	  if lbjdat ^=. then ZGDTC=put(lbjdat, is8601da.);
	  output;
	  end; 
	  %mend zg;

data tpt1;
length usubjid $19 zgtest zgtestcd zgorres zgtpt zgstat zgtpt $100 zgdtc zgorresu $50 ;
set db.lbj (where=(lbjperf_display='Yes' and formname ^= 'BLANK'));

  if not missing(subject) then usubjid = 'PVP101-01-' || Strip(subject);

  	%zg (1,LBJND1_DISPLAY, 'NOT DONE', 'Not Done Pre', 'ZGPRE', '','' );
	%zg (1,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (1,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU1_DISPLAY);

keep usubjid zgtest zgtestcd zgorres zgtpt zgstat zgtpt zgdtc zgorresu zgtptnum;
run;



/***NEED TO GET THESE TO OUTPUT WITH EACH TIMEPOINT CHANGE***/




	%zg (2,LBJND2_DISPLAY, 'NOT DONE', 'Not Done Post 15', 'ZGPOST15', '','' );
	%zg (2,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (2,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU2_DISPLAY);

	%zg (3,LBJND3_DISPLAY, 'NOT DONE', 'Not Done Post 20', 'ZGPOST20', '','' );
	%zg (3,LBJPHc, '', 'pH', 'pH', LBJPHc,'' );
	%zg (3,LBJTEMPc, '', 'Temperature', 'TEMP', LBJTEMPc, LBJTEMPU3_DISPLAY);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 22:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561250#M157085</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2019-05-23T22:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro out putting only first call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561252#M157087</link>
      <description>&lt;P&gt;First figure out what code you want to generate. Then figure how (if) using a macro can help you generate that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you already have a macro you can run it with MPRINT option turned on so that you can see a copy of the code it generates.&amp;nbsp; Does that code look like what you thought it would generate?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you say it doesn't do what you want copy the generated coded and make a program.&amp;nbsp; Then adjust the program until it does work.&amp;nbsp; Then modify the macro to generate the code that works.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 22:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561252#M157087</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-23T22:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro out putting only first call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561257#M157088</link>
      <description>&lt;P&gt;Without data haven't a clue what this is supposed to actually do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if maybe in your macro isn't part of the issue. You make 3 calls with &amp;amp;t=1. So for each of those with the same value of &amp;amp;t the&amp;nbsp;generated code is exactly the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if LBJTPT&amp;amp;t ^='' and &amp;amp;zgvar ^='' then do;
	
	  zgtpt=strip(LBJTPT&amp;amp;t);
	  zgtptnum=&amp;amp;t;

	  LBJPHc= strip(put(LBJPH&amp;amp;t,best.));
	  LBJTEMPc=strip(put(LBJTEMP&amp;amp;t,best.));
&lt;/PRE&gt;
&lt;P&gt;And this indicates you have something in a wide format to have multiple variables with the same suffix you are representing with t.&lt;/P&gt;
&lt;P&gt;Perhaps transposing the data could remove the need to parse across the blocks of variables.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2019 23:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-out-putting-only-first-call/m-p/561257#M157088</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-23T23:26:15Z</dc:date>
    </item>
  </channel>
</rss>

