BookmarkSubscribeRSS Feed
AmelieP25
Calcite | Level 5

I have imported a file that has column names. One of them is biomf and bourgf. I then want to analyse the data in those columns but it says 

ERROR: Variable biomf in list does not match type prescribed for this list. (The same for bourgf)

 

/** Import an XLSX file. **/

PROC IMPORT DATAFILE="/folders/myshortcuts/Myfolders/D_2015.xlsx"
OUT=WORK.chiend15
DBMS=XLSX
REPLACE;
RUN;

/** Print the results. **/

PROC PRINT DATA=WORK.chiend15; RUN;

 

proc glm data=work.chiend15;
class trt bloc;
model biomf bourgf=trt bloc;
means trt;

7 REPLIES 7
RyanMcGovern
Obsidian | Level 7

what are the formats for these two variables? I would guess that SAS is importing them as characters or something unexpected.

AmelieP25
Calcite | Level 5

SAS is importing them as alphanumeric...

RyanMcGovern
Obsidian | Level 7

were you expecting them to be continuous? can i have an example of what your data looks like?

AmelieP25
Calcite | Level 5

it worked when i changed the data in excel from 6.08 to 6,08 for example so now it reads the data as numeric data ! 

 

RyanMcGovern
Obsidian | Level 7

nice, i knew something was off with the data import. glad the results are as expected now.

ballardw
Super User

When using Proc Import with XLS and XLSX files the Excel data engine looks at the first few rows of data and then describes that to SAS. If any of the first few rows has something that might be interpretted as character, even just a second row of column headings, then the data will be treated as text not numeric.

 

You might want to consider running Proc Contents after any import of XLS or XLSX using Proc Import to see if the variables are as you expect.

 

Also a common issue when going to combine multiple files that you think have the same layout is one import with character and another with numeric in the same column, which will cause errors when combining, or different lengths for character variables which will generate warnings and possibly result in truncated data.

Ksharp
Super User

Maybe variable biomf turn into CHARACTER not NUMERIC .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 7 replies
  • 1142 views
  • 0 likes
  • 4 in conversation