BookmarkSubscribeRSS Feed
stinkydog
Calcite | Level 5

Hi,

 

I am using SAS University edition, the most recent version.  

 

I am having trouble with a data set that contains variable columns that have negative numbers.  These numbers are from an excel spreadsheet.  When I input the data set by double clicking on it, then run the program generated, the variable columns with negative numbers are classified as character instead of numeric. I have attached a copy of the dataset.

 

This is the code that is automatically generated when I double click on the TAMDATA.xlsx file in myfolders:

/* Generated Code (IMPORT) */
/* Source File: TAMDATA.xlsx */
/* Source Path: /folders/myfolders */
/* Code generated on: 5/7/17, 3:19 PM */
%web_drop_table(WORK.TAMDATA);

FILENAME REFFILE '/folders/myfolders/TAMDATA.xlsx';
PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.TAMDATA;
GETNAMES=YES;
RUN;
PROC CONTENTS DATA=WORK.TAMDATA; RUN;

%web_open_table(WORK.TAMDATA);

 

3 REPLIES 3
Reeza
Super User

It likely has nothing to do with negative numbers. More likely you have blanks in some cells. Make sure the first 10 rows have numbers. 

stinkydog
Calcite | Level 5
So, I figured it out. It was similar to what you said. It had nothing to do with the negative numbers. About 40 lines down I have some missing information. When I used SAS Studio through SAS University edition about a year and a half ago, as well as previous older SAS editions, missing information needed to be dealt with by using "." Or something like it. With this version I deleted the "." And just left the cells blank and SAS recognized the columns of negative number values as Numeric variables. Now it seems to be working fine. I did not realize this update cleared up the issue with blank spaces.

Thanks for your help!
Tom
Super User Tom
Super User

There is a difference between reading from a XLSX file where SAS can check how the cell is defined and reading from a text file. When reading from a text file if you are doing a simple list more input statement (input var1 var2 varr3) then you need to have something other than spaces for the missing values otherwise SAS will read the other numbers into the wrong column. So the period serves this purpose.  

 

But to store a period in a Excel file you need to make the cell be a character string. So when SAS read the Excel sheet with periods in it had to make the variable character to be able to store the strings that were in some of the cells in the column.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 3466 views
  • 0 likes
  • 3 in conversation