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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1569 views
  • 2 likes
  • 4 in conversation