BookmarkSubscribeRSS Feed
AaronJ
Obsidian | Level 7

I'm using SAS University and i copied and pasted a program into a new program window, gave it a name etc. It's ready to run. I run just the import statement, it imports it fine. I run the data statement, it runs just fine. However, when i try to run the Proc Univariate statement, i get: "Variable GLDcm in list does not match type prescribed for this list." It's just a column of numbers in an excel file.

The same type of file, with the same type of columns of numbers, ran just fine in the other program, but now it won't run. However, if i convert GLDcm to logGLD using the logGLD=log(GLDcm); statement, then the Proc Univariate runs fine. I want to see if the untransformed data is normally distributed, so i don't want to do logGLD if it's not necessary.

1) Why won't SAS University recognize the column of data GLD_cm?

if that can't be resolved, 

2) how can i un-transform the logGLD back into regular numbers so that SAS will read the data?

 

Here's the code as i have it now:

%web_drop_table(WORK.IMPORT);

FILENAME FILEREF '/folders/myfolders/TreeGrowth.xlsx';

PROC IMPORT DATAFILE=FILEREF
DBMS=XLSX
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

data TreeGrowth;
set import;
if Hgt="Ht";

logGLD=log(GLDcm);
logDBH=log(DBHcm);
logHeight=log(Height);
run;

/*proc print data=TreeGrowth;
run;*/

proc univariate Normal Plot data=TreeGrowth;
var GLDcm logGLD;
Histogram GLDcm logGLD/Normal;
QQPLOT GLDcm logGLD;
output out=AllEvents;
run;

.........................................


Thanks for the help

2 REPLIES 2
PaigeMiller
Diamond | Level 26

If you are importing from Excel, sometimes a column of numbers (as seen by the human observer) is actually considered character, and thus not appropriate in PROC UNIVARIATE (one of the many drawbacks of using Excel files).

 

So you need to examine the output from PROC CONTENTS to see if this variable is character or numeric. Also, there are options in PROC IMPORT (if that's what you are using) that can force columns to be numeric.

--
Paige Miller
Reeza
Super User

@AaronJ wrote:

I'm using SAS University and i copied and pasted a program into a new program window, gave it a name etc. It's ready to run. I run just the import statement, it imports it fine. I run the data statement, it runs just fine. However, when i try to run the Proc Univariate statement, i get: "Variable GLDcm in list does not match type prescribed for this list." It's just a column of numbers in an excel file.

The same type of file, with the same type of columns of numbers, ran just fine in the other program, but now it won't run. However, if i convert GLDcm to logGLD using the logGLD=log(GLDcm); statement, then the Proc Univariate runs fine. I want to see if the untransformed data is normally distributed, so i don't want to do logGLD if it's not necessary.

1) Why won't SAS University recognize the column of data GLD_cm?

if that can't be resolved, 

2) how can i un-transform the logGLD back into regular numbers so that SAS will read the data?

 

Here's the code as i have it now:

%web_drop_table(WORK.IMPORT);

FILENAME FILEREF '/folders/myfolders/TreeGrowth.xlsx';

PROC IMPORT DATAFILE=FILEREF
DBMS=XLSX
OUT=WORK.IMPORT;
GETNAMES=YES;
RUN;

data TreeGrowth;
set import;
if Hgt="Ht";

logGLD=log(GLDcm);
logDBH=log(DBHcm);
logHeight=log(Height);
run;

/*proc print data=TreeGrowth;
run;*/

proc univariate Normal Plot data=TreeGrowth;
var GLDcm logGLD;
Histogram GLDcm logGLD/Normal;
QQPLOT GLDcm logGLD;
output out=AllEvents;
run;

.........................................


Thanks for the help


  1. Excel doesn't force types on fields so SAS has to guess and with any guesses, it can be wrong. For example, if your file has a few missing first it will assume its character. If it has NA or . it may also assume it is missing. Some options to fix this:
    1. Make sure the cell is formatted as numeric in Excel and that there are no characters in any of the values. 
    2. Convert the file to a CSV and import it that way. Use GUESSINGROWS=MAX or check the code and customize it to import the file with the types you need.
  2. You can use INPUT() to convert the value to a numeric, but make sure to save it to a new name.
  3. new_num = input(old_name, 8.);

 

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
  • 2 replies
  • 788 views
  • 1 like
  • 3 in conversation