BookmarkSubscribeRSS Feed
copony
Calcite | Level 5

I'm relatively new to the DATA and PROC IMPORT steps of SAS (am more statistics oriented and have not managed importing data into SAS, specifically) and I'm wondering if there is a way to import specific rows into SAS. The problem with my Excel sheets is that they contain a lot of data in rows that I don't need. Also, the first line of the Excel sheet is not a list of variable names (I didn't design these spreadsheets, obviously!).

Specifically, this is what I need to do:

Import cell B2 (this is study ID#) and then import A10, B10 and A11, B11. Then I would like B12 - Y12 (these are time variables) and then B24 - Y24 (the values that correspond to B12-Y12 variables).

Anything in an A cell is a variable, but I don't necessarily NEED it as I could figure out what variable I'm looking at later on.

There are multiple worksheets in each workbook, and I am willing to read each workbook/worksheet in by hand if necessary.

Ordinarily I would run a macro/VBA in Excel to get this info but our security policies are such that we aren't allowed to run macros in Excel or Access!

All suggestions appreciated!9

2 REPLIES 2
user24feb
Barite | Level 11

Something like:

Proc Import Datafile = "C:\Path\XL_FILE.xlsx" /* change path and name */

        Out = SAS_XL_File

        DBMS = Excel2007 /* .. if it is XL 2007 .. */

        Replace;

  Getnames=Yes; /* .. the first line will become the variable names */

  Range="Sheet1$B12:Y12";  /* don't forget the $ between sheet name and the Excel cells .. */

Run;

jakarman
Barite | Level 11

This is an duplicate question there is also an answer from pgstats

---->-- ja karman --<-----

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2879 views
  • 0 likes
  • 3 in conversation