Dears, I want to deliver value of macro variable within one data step, there are two datasets named DS_SUMMARY and DS_SURVIVAL, each one have three time related variables which I need to transform to Character type to compare the value. I wonder if resolve() function could deal with this. The problem is when it comes to the code "if dsvar='N' then do.....else if dsvar='C' then do...;", it can not jump into the right %iso8601 section by execute two conditions one by one. So I wonder how could this be resolved? followed by data: 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; %macro find();
proc sql noprint;
select distinct memname into: alldataset separated by "|" from content;
select count(distinct memname) into: ndata from content;
quit;
%put &sqlobs;
%do i=1 %to &ndata;
%let rawdata=%scan(&alldataset, &i, |);
proc sql noprint;
select name into: datlist separated by '| ' from content where memname="&rawdata";
select strip(name)||%trim("_c") into: vardtc separated by ' ' from content where memname="&rawdata";
quit;
%let datnum=%eval(%sysfunc(count("&datlist",%str(|)))+1);
data _test&i;
set raw.&rawdata;
length x&i rawdata&i $50.;
rawdata&i="&rawdata";
usubjid=catx("-",studyid,siteid,substr(subjid,3,3));
%do j=1 %to &datnum;
%let datdone=%scan(&datlist, &j, |);
call symputx('type',vtype(&datdone));
dsvar=resolve('&type');
if dsvar='N' then do;
%iso8601(dtin=put(&datdone,yymmdd10.),dtout=&datdone._c);
end;
else if dsvar='C' then do;
%iso8601(dtin=&datdone,dtout=&datdone._c);
end;
&datdone._c=substr(&datdone._c,1,10);
%end; run; %end;
%mend; Problem: 1."if dsvar='N' then do.....else if dsvar='C' then do...;", it can not jump into the right %iso8601 section by execute two conditions one by one. 2. put(UNBLNDTC,yymmdd10.) --------- 484
... View more