************ques1 20200122**************;
libname mysas "D:\W\Code_lib";
libname lookup "D:\W\Code_lib";
%let sdtm=QS;
data work.fmtlib&sdtm.3;
length FmtName $64 Start $160 End $160 Type $16;
set mysas.fmt&sdtm.clean(drop=Length);
fmtname=compress(CodeList||"_"||Variable);
if CodeList in ("DOMAIN", "VISITPRJ5457", "YNULL", "QSTEST", "QSTESTCD") then do;
start=sourcevar2;
end=sourcevar2;
end;
else do;
start=sourcevar1;
end=sourcevar1;
end;
label=left(SDTMcode);
if upcase(type) in ("CHAR") then type="C";
else if upcase(type) in ("NUM") then do;
if ifc(prxmatch('/^-?\d*\.?\d+\s*$/',sourcevar2),'Num','Char')='Num' then type="N";
else type="I";
end;
run;
proc sort data=work.fmtlib&sdtm.3 out=work.fmtlib&sdtm.4;
by FmtName;
run;
proc format cntlin=work.fmtlib&sdtm.4 library=lookup maxselen=160 maxlablen=300;
run;
proc catalog c = lookup.formats;
contents;
run;
proc format library = lookup.formats
cntlout = cntlout;
run; Hi dimpz429 , attached the code, you can refer to. you forget another type='I', please see the example as below, pay attention to the type of sex, which is same as VISITNUMPRJ5457 CodeList VISITNUMPRJ5457 proc format;
value $month
"Jan"="01"
"Feb"="02"
"Mar"="03"
"Apr"="04"
"May"="05"
"Jun"="06"
"Jul"="07"
"Aug"="08"
"Sep"="09"
"Oct"="10"
"Nov"="11"
"Dec"="12"
;
invalue sex
"M"=1
"F"=2
;
value ny_a /* type='I'-- type of start is character, type of start label is numeric*/
1="Y"
2="N"
;
run;
proc format library=work cntlout=fmt;
run;
... View more