03-11-2015 03:08 AM
Good morning all,
while importing excel there is a problem.
if the excel data contains some data and some title statement.
I know how to import it into sas, But is there any possible chance to import title also while importing.
the data is like this
ABC company ltd
Employee details on 11/03/2015
under the data is as follows in cell
DATE EMP_ID ENAME SALARY
so these kind of data how we import it into sas.
Through proc print it is possible. But through data step is there any possible to import with title also.
Thanks in advance.
03-11-2015 04:03 AM
You could try to store the "title" in an additional column, and write a data step so that it detects the title(s) line(s) and assigns these values to retained variables. Every record in the SAS dataset will then also hold the title(s) data.
Or you could preserve the title(s) in macro variables and then use these to set a label for the whole dataset.
proc import will not be able to handle this, as it already needs a database-like table structure in the input data.
03-11-2015 05:37 AM
I think we covered this in your other question. Excel is a free-for-all bearing no resemblance to any other method of working. You need to have the concept of "data" ie tabular, fixed structure dataitems, and presentation - layouts, titles, footnotes etc. separate. How you go about doing this can be a matter of taste. You could for instance write a VBA macro which pulls all titles out, saves them to their own CSV for importing, then pulls the data out and saves that to a CSV. You could also go directly into the XLSX file (if thats what it is) and pull certain elements out. A third option would be to use a libname statement to Excel and pull out certain elements from that: http://www2.sas.com/proceedings/sugi31/024-31.pdf
So to finish, your problem is Excel. Fix that, there are a multitude of data transfer formats around - CSV, XML, Json, Delimited, DB etc. use one of those and your life will be far easier.