- proc format;
- value afmt
- low-<0 = "na"
- 0-1 = [pvalue4.]
- >1-10 = "low"
- >10-30 = "stage 1"
- >30-60 = "stage 2"
- >60-120 = "stage 3"
- >120-high = "haha"
- ;
- value bfmt
- 0 = "False"
- 1 = "True"
- ;
- value cfmt
- 0,1=[bfmt5.]
- 90-high="impossible"
- low-<0="missing"
- other = [afmt6.]
- ;
无论从dictionary.formats或sashelp.vformat都看不出来,而用PROC FORMAT CNTLOUT=导出的数据集里也只能发现它嵌套了别的FORMAT(s)。
- proc sql;
- select * from dictionary.formats where fmtname="CFMT" and fmttype="F";
- proc format cntlout = a;
- select cfmt;
- quit;
我能想到的做法是逐层找。谁有更简单的办法的话,我给他/她报销到我们巴东一游!
- %macro is_picture_format(fmtname=, tmpdsn=);
- %local fmtlib i picture_formats nested_formats;
- %let nested_formats = 0;
- %let fmtlib = ;
- proc sql noprint;
- select cats(libname, '.', memname) into :fmtlib from dictionary.formats
- where libname NE '' and fmtname eq upcase("&fmtname") and fmttype eq 'F';
- quit;
- %if &fmtlib eq %str() %then %do;
- %let picture_format=1;
- %goto exit;
- %end;
- %else %do;
- proc format CNTLOUT=&tmpdsn(KEEP=label type hlo) library=&fmtlib;
- select &fmtname;
- run;
- proc sql noprint;
- select cats(count(*)) into :picture_formats from xxx
- where type = 'P';
- quit;
- %if &picture_formats>0 %then %do;
- %let picture_format = 1;
- %goto exit;
- %end;
- %else %do;
- %local nested_formats;
- proc sql noprint;
- select cats(count(*)) into :nested_formats from &tmpdsn
- where hlo like '%F%';
- %do i = 1 %to &nested_formats;
- %local fmtname&i;
- %end;
- %if &nested_formats>0 %then %do;
- %let nested_format = 1;
- select substr(label, 1, findc(label, '.1234567890', -32767, 'iv'))
- into :fmtname1-:fmtname&nested_formats from &tmpdsn
- where hlo like '%F%';
- %end;
- quit;
- %do i=1 %to &nested_formats;
- %is_picture_format(fmtname=&&fmtname&i);
- %if &picture_format>0 %then %goto exit;
- %end;
- %end; %*end of not (if &picture_formats>0);
- %end; %*end of not (if &fmtlib = );
- %exit:
- %mend is_picture_format;
- %let picture_format=0;
- %is_picture_format(fmtname=cfmt, tmpdsn=giglo);
- %put picture_format=&picture_format;


雷达卡




京公网安备 11010802022788号







