I am trying import the excel file into sas, for some reason, I am running into issues where row I want to display as variable is not working properly. Any help greatly appreciated. I want titles as variable names and read it as data from the next row.
PROC IMPORT
OUT= YourNewTable
DATAFILE= "myfolder/excelfilename.xlsx"
DBMS=xlsx
REPLACE;
SHEET="Sheet1";
GETNAMES=YES;
range="Sheet1$A2:L4"
RUN;
I used above code, I am getting dataset , variable name as sponsor information then A,B,C . below is the excel sheet
The first row of the file provides the information that SAS uses to create variable names. Since you have two rows of "header" information the results are as you describe. Delete the entire row that contains the "Sponsor Information".
Then import.
@SASuserlot wrote:
I tried as u suggested, now I am getting the A. B, C.. in varaible I used the rang="sheet1$A2:L5". If possible can you write a code
remove the range or change it to read the first row.
I really don't use ranges but suppose sheet1$A1:L4 should work.
PROC IMPORT
OUT= SDSP
DATAFILE= "C:\Users\xxx\Desktop\New folder\xx\1.xlsx"
DBMS=xlsx
REPLACE;
SHEET="Sheet1";
GETNAMES=yes;
range="Sheet1$A2:0";
/* SCANTEXT=YES;*/
/* USEDATE=YES;*/
/* SCANTIME=YES;*/
RUN;
@SASuserlot - What happens if you remove the RANGE statement?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.