Help using Base SAS procedures

how to import excel along with title

Reply
Frequent Contributor
Posts: 111

how to import excel along with title

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.

Super User
Posts: 7,854

Re: how to import excel along with title

Posted in reply to Ravikumarkummari

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,988

Re: how to import excel along with title

Posted in reply to Ravikumarkummari

Hi,

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.

Ask a Question
Discussion stats
  • 2 replies
  • 195 views
  • 0 likes
  • 3 in conversation