When Reading EXCEL files have an option to automatically replace characters that are not legit in variable names.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

When Reading EXCEL files have an option to automatically replace characters that are not legit in variable names.

Art Kendall
I frequently receive Excel files that have column heading like
"Date of Birth" "Home Address" "Zip+4" "1994 Income"

Some times there are higher level headings, titles, etc. which I can work around by defining a range.

Now I go into the spreadsheet and manually remove characters that are illegal in variable names.
and do something like

GET DATA /TYPE=XLSX
  /FILE='C:\Users\Art\Desktop\Demo illegal variable names.xlsx'
  /SHEET=name 'Sheet1'
  /CELLRANGE=full
  /READNAMES=on
  /ASSUMEDSTRWIDTH=200.
EXECUTE.


Unless I missed something, how about  options like

   /READNAMES=2 IllegalChar= (blank="") (else="@")
  /FIRSTCASE = 5
 

So the variable names become

DateofBirth HomeAddress Zip@4 @1994Income

-------------------------------
please try to input the attached EXCEL file.  What do you get as variable labels?
<help> says


Read variable names. You can read variable names from the first row of the file or the first row of the defined range. Values that don't conform to variable naming rules are converted to valid variable names, and the original names are used as variable labels.

If I read in the attached excel file, the variable labels are blank.
I am running 21.0.0.1 under 64bit Windows 8.
-- 
Art Kendall
Social Research Consultants

Demo illegal variable names.xlsx (12K) Download Attachment
Art Kendall
Social Research Consultants