保持列具有特定格式

时间:2018-11-12 15:28:28

标签: sas

我只想保留具有特定格式的列。例如,sashelp.cars有2列格式为DOLLAR的列-MSRPINVOICE。我只想保留这两列。任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:2)

您可以使用dictionary.columns来做到这一点。

 proc sql ;
    select name into :keepcols SEPARATED by " " from dictionary.columns
    where libname = "SASHELP"
     and memname = "CARS"
     and format = "DOLLAR8.";

Edit1:您可以使用“ DOLLAR%”之类的格式来查找所有采用美元格式的文件;

  proc sql ;
     select name into :keepcols SEPARATED by " " from dictionary.columns
     where libname = "SASHELP"
    and memname = "CARS"
     and format like "DOLLAR%";



      data cars;
        set sashelp.cars(keep = &keepcols);
     run;