CPak
CPak

Reputation: 13591

keep columns with specific format

I'd like to keep only columns with specific formatting. For instance, sashelp.cars has 2 columns with DOLLAR format - MSRP & INVOICE. I'd like to keep only these two columns. Any help is appreciated!

Upvotes: 1

Views: 59

Answers (1)

Kiran
Kiran

Reputation: 3315

you can use dictionary.columns and can do this.

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

Edit1: You can use format like "DOLLAR%" to find all with dollar formats;

  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;

Upvotes: 2

Related Questions