Wednesday 15 April 2015

Is there a way to search headers that contain a certain string in SAS then apply format changes to all of them -



Is there a way to search headers that contain a certain string in SAS then apply format changes to all of them -

say have headers name (char32), birth_date(best32), , application_date (best32). there way utilize proc procedure search headers contain "_date" , alter format of results. in case end name (char32), birth_date(date9), , application_date (date9)

there lots of ways solve this. method below uses dictionary.columns view in proc sql columns want. constructs macro variable can used in proc datasets alter format.

data have; format name $32. birth_date application_date best32.; name = "x"; birth_date = "04jul1776"d; application_date = today(); run; proc sql noprint; select name :tochange separated " date9. " dictionary.columns libname="work" , memname="have" , upcase(name) '%_date'; quit; %put &tochange; proc datasets lib=work nolist; modify have; format &tochange date9.; run; quit; proc print data=have; run;

sas

No comments:

Post a Comment