Here is the solution if anybody needs it. /** sample data set **/ data sortedsrc; claimid=123; memid=1; run; data sortedsrc2; claimid='123'; memid=1; run; %macro lst(dsn); /** open dataset **/ %let dsid=%sysfunc(open(&dsn)); /** retrieve the type of the variable claimid and place in macro variable &typ **/ %let x=%sysfunc(varnum(&dsid,claimid)); %let typ=%sysfunc(vartype(&dsid,&x)); /** close dataset **/ %let rc=%sysfunc(close(&dsid)); data final_&dsn; set &dsn; by MemID; retain INI_:; %if &typ = C %then %do; length INI_ClaimID $60. ; if first.MemID then do; INI_ClaimID = ' '; end; %end; %else %do; length INI_ClaimID 8. ; if first.MemID then do; INI_ClaimID = .; end; %end; run; %mend lst; %lst(sortedsrc); %lst(sortedsrc2);
... View more