BookmarkSubscribeRSS Feed
Daily1
Quartz | Level 8
proc import out= df
    datafile = 'df.xlsx'
    dbms = xlsx 
	replace;
    getnames=no;
	datarow=2;
run;

Excel file

Daily1_0-1654687342294.png

my varibles names not properly display

column name is epd year vc code

 

 

 

9 REPLIES 9
PaigeMiller
Diamond | Level 26

Can you show us the results as seen in SAS (not Excel)?


Can you show us the PROC IMPORT code you used?

 

Also, can you explain in more detail what is wrong?

--
Paige Miller
Daily1
Quartz | Level 8

SAS output

Daily1_0-1654690261638.png

epd year vc code is my column name i want

 

 

PaigeMiller
Diamond | Level 26

@Daily1 wrote:

SAS output

Daily1_0-1654690261638.png

epd year vc code is my column name i want

 

 


I don't understand what the problem is. Your variable names shown are epd year vc code. Please explain further.

--
Paige Miller
Daily1
Quartz | Level 8

brother just i want this type of output

Daily1_0-1654690938536.png

 

PaigeMiller
Diamond | Level 26

I'm not understanding. You need to EXPLAIN. Do not write one brief sentence that repeats what you have already said; you need to provide new information, explaining what you want in detail so I can understand what the issue is. At no point have you explained your problem with the variable names.

--
Paige Miller
Tom
Super User Tom
Super User

Your data starts in A2 instead of A1.  You need to tell PROC IMPORT to do the same.

proc import out= df replace
    datafile = 'df.xlsx' dbms = xlsx 
;
  range='$A2:';
run;
Daily1
Quartz | Level 8
%macro pim(sheet);
proc import out= df.&sheet replace
datafile = 'df.xlsx' dbms = xlsx ;
range='&sheet$A2:';
run;
%mend pim;
%pim(A);

A is a sheet1 name 

 

SAS log error

 

Couldn't find sheet in spreadsheet
Requested Input File Is Invalid
ERROR: Import unsuccessful. See SAS Log for details.

 

 

 how to import multiple sheets using Proc Import.

Kurt_Bremser
Super User

Single quotes prevent macro variables from being resolved.

And this can not work:

out= df_'&sheet'

Dataset names must not contain quotes.

Kurt_Bremser
Super User

Two issues:

Your column names are in row 2, so you must use a range (see @Tom 's post). Alernatively, you can remove row 1 from the spreadsheet before importing it.

And your GETNAMES=NO statement explicitly prevents SAS from retrieving the variable names from the spreadsheet, so don't be surprised when SAS does what it is told to do.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 9 replies
  • 575 views
  • 2 likes
  • 4 in conversation