<?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: Help with SAS Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990102#M380258</link>
    <description>&lt;P&gt;Thank you! It works out in the program and removed SAS warning.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jun 2026 17:39:36 GMT</pubDate>
    <dc:creator>xliu1</dc:creator>
    <dc:date>2026-06-25T17:39:36Z</dc:date>
    <item>
      <title>Help with SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990093#M380256</link>
      <description>&lt;P&gt;Attached is the macro definition. The programs runs and returns the expected results. But I get warning in the SAS log. The college list is supposed to be:&amp;nbsp;A&amp;amp;S,AICC,BCS,DRP,EDU,ENG,HLTH,MBUS,NUR,OUS. When I call the macro, I get warning in the SAS log: How can I fix the code to remove the warning? Thanks.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xliu1_0-1782404601279.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/116052i0EF458C749C25233/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xliu1_0-1782404601279.png" alt="xliu1_0-1782404601279.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro fit_autoreg_params;

  data cohort_params_all;
    length college $32 parameter $32 estimate 8;
    stop;
  run;

  data selected_vars_all;
    length college $32 variable $32 model_status $20;
    stop;
  run;

  %let n=%sysfunc(countw(%superq(college_list), %str(,)));

  %do i=1 %to &amp;amp;n;

    %let this_college=%scan(%superq(college_list), &amp;amp;i, %str(,));

    data hist_one;
      set cohort_hist;
	  where college=%tslit(&amp;amp;this_college);
      *where college = "&amp;amp;this_college";
      time_c = cohort_yr - &amp;amp;mean_year;
    run;

    data hist_one_recent;
      set hist_one;

      if college eq "OUS" and cohort_yr &amp;lt;= 2006 then delete;
      if college eq "NUR" and cohort_yr = 2006 then delete;
    run;

    proc sql noprint;
      select count(*) into :nobs trimmed
      from hist_one_recent;
    quit;

    %if &amp;amp;nobs &amp;gt;= 6 %then %do;

      ods exclude all;
      ods output ParameterEstimates=pe_one;

      proc autoreg data=hist_one_recent;
        model COHORT_6YR =
              time_c female_perc sch100_perc gpa2_perc senior_perc
              / nlag=1 method=ml backstep dw=5 dwprob;
      run;
      quit;

      ods select all;

      data pe_one2;
        length college $32 parameter $32 estimate 8;
        set pe_one(rename=(Variable=_Variable Estimate=_Estimate));
        
		college=%tslit(&amp;amp;this_college);
        *college = "&amp;amp;this_college";
        parameter    = strip(_Variable);
        estimate     = _Estimate;

        if upcase(parameter) = "AR1" then delete;

        keep college parameter estimate;
      run;

      proc append base=cohort_params_all data=pe_one2 force;
      run;

      data selected_one;
        length college $32 variable $32 model_status $20;
        set pe_one(rename=(Variable=_Variable));

		college=%tslit(&amp;amp;this_college);
        *college = "&amp;amp;this_college";
        variable     = strip(_Variable);
        model_status = "backstep_kept";

        if upcase(variable) = "AR1" then delete;

        keep college variable model_status;
      run;

      proc append base=selected_vars_all data=selected_one force;
      run;

    %end;

    %else %if &amp;amp;nobs &amp;gt;= 2 %then %do;

      /* Trend fallback: COHORT_6YR = Intercept + time_c */

      proc sort data=hist_one_recent;
        by cohort_yr;
      run;

      ods exclude all;
      ods output ParameterEstimates=pe_fallback;

      proc reg data=hist_one_recent;
        model COHORT_6YR = time_c;
      run;
      quit;

      ods select all;

      data pe_one2;
        length college $32 parameter $32 estimate 8;
        set pe_fallback(rename=(Variable=parameter Estimate=estimate));

		college=%tslit(&amp;amp;this_college);
        *college = "&amp;amp;this_college";

        keep college parameter estimate;
      run;

      proc append base=cohort_params_all data=pe_one2 force;
      run;

      data selected_one;
        length college $32 variable $32 model_status $20;
        college=%tslit(&amp;amp;this_college);
		*college = "&amp;amp;this_college";

        variable = "Intercept"; model_status = "fallback_trend"; output;
        variable = "time_c";    model_status = "fallback_trend"; output;
      run;

      proc append base=selected_vars_all data=selected_one force;
      run;

    %end;

    %else %do;

      /* Very sparse fallback: flat last observed value */

      proc sort data=hist_one_recent;
        by cohort_yr;
      run;

      data _null_;
        set hist_one_recent end=lastobs;
        if lastobs then call symputx('last_cohort', COHORT_6YR);
      run;

      data pe_one2;
        length college $32 parameter $32 estimate 8;
        college=%tslit(&amp;amp;this_college);
        *college = "&amp;amp;this_college";

        parameter = "Intercept"; estimate = &amp;amp;last_cohort; output;
        parameter = "time_c";    estimate = 0;            output;
      run;

      proc append base=cohort_params_all data=pe_one2 force;
      run;

      data selected_one;
        length college $32 variable $32 model_status $20;
        college=%tslit(&amp;amp;this_college);
        *college = "&amp;amp;this_college";

        variable = "Intercept"; model_status = "fallback_flat"; output;
        variable = "time_c";    model_status = "fallback_flat"; output;
      run;

      proc append base=selected_vars_all data=selected_one force;
      run;

    %end;

  %end;

%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2026 16:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990093#M380256</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2026-06-25T16:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990097#M380257</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317497"&gt;@xliu1&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0mnb8dwzghn9cn1cokdgg9xixg6.htm" target="_blank" rel="noopener"&gt;%QSCAN&lt;/A&gt; instead of &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nhhymw6gxixvn1johcfl6kaygw.htm" target="_blank" rel="noopener"&gt;%SCAN&lt;/A&gt; should resolve the issue, as it masks the ampersand (macro trigger) in "A&amp;amp;S".&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4" color="#999999"&gt;%let this_college=%&lt;STRONG&gt;&lt;FONT color="#993366"&gt;q&lt;/FONT&gt;&lt;/STRONG&gt;scan(%superq(college_list), &amp;amp;i, %str(,));&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jun 2026 16:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990097#M380257</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2026-06-25T16:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990102#M380258</link>
      <description>&lt;P&gt;Thank you! It works out in the program and removed SAS warning.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2026 17:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-SAS-Macro/m-p/990102#M380258</guid>
      <dc:creator>xliu1</dc:creator>
      <dc:date>2026-06-25T17:39:36Z</dc:date>
    </item>
  </channel>
</rss>

