<?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: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643449#M192025</link>
    <description>&lt;P&gt;Because %iso8601 is a standard macro used within Cor.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's true those data are messed up and type need to be deal with...&lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 01:34:31 GMT</pubDate>
    <dc:creator>Elaine_</dc:creator>
    <dc:date>2020-04-28T01:34:31Z</dc:date>
    <item>
      <title>Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/642996#M191868</link>
      <description>&lt;P&gt;Dears, I want to deliver value of macro variable within one data step,&amp;nbsp; there are two datasets named&amp;nbsp;DS_SUMMARY and&amp;nbsp;DS_SURVIVAL, each one have three time related variables which I need to transform to Character type to compare the value.&amp;nbsp; I wonder if resolve() function could deal with this. The problem is&amp;nbsp; when it comes to the code "if dsvar='N' then do.....else if dsvar='C' then do...;", it can not jump into the right&amp;nbsp; %iso8601 section by execute two conditions one by one. So I wonder how could this be resolved?&lt;/P&gt;&lt;P&gt;followed by data:&lt;/P&gt;&lt;PRE&gt;data WORK.CONTENT;
infile datalines ;
input LIBNAME: $3. MEMNAME: $22. NAME: $12. TYPE: $4. LENGTH: 8.;
label LIBNAME="Library Name" MEMNAME="Member Name" NAME="Column Name" TYPE="Column Type" LENGTH="Column Length";
datalines;
RAW DS_SUMMARY EXLSDAT char 200
RAW DS_SUMMARY UNBLNDTC char 200
RAW DS_SUMMARY PDDAT num 8
RAW DS_SURVIVAL DTHDAT char 200
RAW DS_SURVIVAL LIVEDAT num 8
RAW DS_SURVIVAL LOSTDAT num 8
;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;%macro find();
proc sql noprint;
    select distinct memname into: alldataset separated by "|"   from content;
    select count(distinct memname) into: ndata from content;
quit;
%put &amp;amp;sqlobs;

%do i=1 %to &amp;amp;ndata;
    %let rawdata=%scan(&amp;amp;alldataset, &amp;amp;i, |);
        
    proc sql noprint;
        select name into: datlist separated by '| ' from content where memname="&amp;amp;rawdata";
        select strip(name)||%trim("_c") into: vardtc separated by ' ' from content where memname="&amp;amp;rawdata";
    quit;

    %let datnum=%eval(%sysfunc(count("&amp;amp;datlist",%str(|)))+1);

    data _test&amp;amp;i;
        set raw.&amp;amp;rawdata;
        length x&amp;amp;i rawdata&amp;amp;i $50.;
        rawdata&amp;amp;i="&amp;amp;rawdata";
	    usubjid=catx("-",studyid,siteid,substr(subjid,3,3));
        %do j=1 %to &amp;amp;datnum;
           %let datdone=%scan(&amp;amp;datlist, &amp;amp;j, |);
			call symputx('type',vtype(&amp;amp;datdone));
			dsvar=resolve('&amp;amp;type');
           if dsvar='N' then do;
               %iso8601(dtin=put(&amp;amp;datdone,yymmdd10.),dtout=&amp;amp;datdone._c);
           end;

           else  if dsvar='C' then do;
		   	   %iso8601(dtin=&amp;amp;datdone,dtout=&amp;amp;datdone._c);
           end;
	    &amp;amp;datdone._c=substr(&amp;amp;datdone._c,1,10);
        %end;&lt;BR /&gt;    run;&lt;BR /&gt;&lt;BR /&gt;%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;1."if dsvar='N' then do.....else if dsvar='C' then do...;", it can not jump into the right&amp;nbsp; %iso8601 section by execute two conditions one by one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. put(UNBLNDTC,yymmdd10.)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ---------&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;484&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 07:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/642996#M191868</guid>
      <dc:creator>Elaine_</dc:creator>
      <dc:date>2020-04-26T07:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643429#M192020</link>
      <description>&lt;P&gt;Why don't you start the&amp;nbsp;&lt;SPAN&gt;%iso8601&lt;/SPAN&gt; macro with something like:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%* If the parameter value is a SAS date, then format it ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%if %length(&amp;amp;datdone)=5 %then %let datdone=%sysfunc(putn(&amp;amp;datdone,yymmdd10.));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;instead of trying the address the problem before calling the macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Aside: Is it not a data quality issue if the variable type is unknown?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 22:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643429#M192020</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-27T22:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643442#M192022</link>
      <description>&lt;P&gt;What is this %ISO8601 macro doing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Your SQL steps are working too hard. SAS can count for you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct memname into :alldataset separated by '|' from content;
%let ndata=&amp;amp;sqlobs;
...
select name
     , cats(name,'_C')
into :datlist separated by '|' 
   , :vardtc separated by ' ' 
from content 
where memname="&amp;amp;rawdata"
;
%let datnum=&amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2020 23:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643442#M192022</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-27T23:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643448#M192024</link>
      <description>&lt;P&gt;Thank you for tips! %iso8601 is a common character format which need to transform all numeric to character data type to use this macro.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="捕获.PNG" style="width: 605px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38809i8564E2B1E3D2B5DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="捕获.PNG" alt="捕获.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 01:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643448#M192024</guid>
      <dc:creator>Elaine_</dc:creator>
      <dc:date>2020-04-28T01:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643449#M192025</link>
      <description>&lt;P&gt;Because %iso8601 is a standard macro used within Cor.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's true those data are messed up and type need to be deal with...&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 01:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643449#M192025</guid>
      <dc:creator>Elaine_</dc:creator>
      <dc:date>2020-04-28T01:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643452#M192026</link>
      <description>&lt;P&gt;But WHAT is that macro.&lt;/P&gt;
&lt;PRE&gt;418  data _null_;
419   %iso8601;
      -
      180
WARNING: Apparent invocation of macro ISO8601 not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.

420  run;&lt;/PRE&gt;
&lt;P&gt;How it works makes a difference in how you can USE it.&lt;/P&gt;
&lt;P&gt;If you don't know how it works then write a little example data step that uses and it run it with MPRINT option turned on. Show use the lines in the SAS log that the MPRINT option generates.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 01:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643452#M192026</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-28T01:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Compile and Processing sequence in SAS Macro. Try to resolve macro variable within one data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643460#M192032</link>
      <description>&lt;P&gt;1. Maybe the data should be cleaned rather than add convoluted logic to address the flaws.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Short of that the macro should be improved to accept the different possible values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. I am unsure what this code is trying to achieve, and I have a suspicion it could be coded in a simpler fashion, but as a third option, this should do what you expect:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  NUMVAL=input(cats(&amp;amp;datdone),10.);
  if DSVAR='N' then do;
    %iso8601(dtin=put(NUMVAL,yymmdd10.),dtout=&amp;amp;datdone._c);
  end;
  else if DSVAR='C' then do;
    %iso8601(dtin=NUMVAL,dtout=&amp;amp;datdone._c);
  end;           

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 03:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compile-and-Processing-sequence-in-SAS-Macro-Try-to-resolve/m-p/643460#M192032</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-04-28T03:50:35Z</dc:date>
    </item>
  </channel>
</rss>

