BookmarkSubscribeRSS Feed
viollete
Calcite | Level 5

Hi ,

I need to import excel file. i use this code:

proc import datafile="D:...." out=try

                                         dbms=xls replace;

                                         sheet="sheet3";

                                         getbames=yes;

run;

but my variables names (first line in excel) is dates (12-Nov-2013, 13-Nov-2013, 16-No-2013 to 18-Nov-2013) and I want that the variable names would be like this, but SAS just leave only 16-No-2013 to 18-Nov-2013 and it does not take single dates

How could i fix it?

Thanks

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Firstly, you do not want variable names to be dates.   This just causes you a lot of extra work (i.e. you can't use arrays and such like easily).  Secondly, SAS will not like a number as first character, nor will it allow -, unless you you have forced it too, and it wouldn't be recommended.  Thirdly, as I always do, I recommend not using Excel or Proc Import.  Convert your Excel file to CSV, and write a datastep import.  This gives you, the person who knows the data and how to deal with it, the control over how SAS handles the data rather than SAS guessing what to do.

How does your spreadsheet look?  Maybe post some of it.  If the heading of a column is really "16-No-2013 to 18-Nov-2013" then you have all kinds of problems.  This is caused by Excel and people using that software.  All databases or software which deal with data have a fixed structure, i.e. columns have on format, one title.  Excel does not have that, you can do whatever you like where-ever you like.  If it was me I would send the file back and ask the vendor to supply a proper data transfer format file - CSV, XML etc.  If you can't then somehow you will have to modify the file yourself.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 319 views
  • 0 likes
  • 2 in conversation