As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Use PROC SQL to Create SAS Data sets from Excel files

From sasCommunity
Jump to: navigation, search

If you are a beginner like me and have to work with Excel files, this should help you.

Scenario

Suppose you have an Excel file named abc.xlsx that has multiple sheets and let xyz be one of those sheets. Further, suppose that within that sheet you want to extract data from the region B4:H200 and create a SAS data set. This is how you can accomplish this.

Solution
proc sql;
    connect to Excel (path="L:\Raghu\Desktop\Code\abc.xlsx");
 
    create table SasDataset as
    select *
    from connection to Excel (select * from [xyz$B4:H200]);
 
    disconnect from Excel;
quit;

Note: The code uses column values from the first row to create variable names.

See TS-792