04-27-2015 10:57 AM
My input data has things like spaces and dashes in a SQL table, is there a quick way to convert to SAS names, rather than doing the whole thing like
a."lt-acnt"n as lt_acnt,
a."new-mtg-nbr"n as new_mtg_nbr,
04-27-2015 11:20 AM
Well, the options validavarname=any; will allow you to work with these:
You can then easily post-process the metadata something like:
set sashelp.vcolumn (where=(libname="WORK" and memname="HAVE")) end=last;
if _n_=1 then call execute('data want; set have (rename=(');
if last then call execute('));run;');
04-27-2015 11:23 AM
That's a decent idea, using the dictionary tables.
I don't create the data, so using vvn=v7 to convert on the input is not an option.
04-27-2015 12:17 PM
In case this is of any help, the code sample below will translate all sorts of characters which are not valid for a SAS Name into an underscore. Beside that I would recommend Proc DATASETS with the RENAME statement, this way you avoid reading the again.
04-27-2015 11:21 AM
How where the original SAS Data Sets created? Using the Import task from EG or Proc Import or ...
If you are using SAS Enterprise Guide, it will set the SAS System Option VALIDVARNAME=ANY. This might be the cause of the names you are seeing.
You can use options validvarname=v7; so that Proc IMPORT creates names with underscores at places where the original name had blanks