BookmarkSubscribeRSS Feed
dustychair
Pyrite | Level 9

Hi all,

I am importing some excel and csv files and then trying to merge them. There is an "ID" variable in one of those files and there are specifically two ID values there that SAS cannot match those values with the relevant variables in the other files.

For example, in my data there is an ID value of "1169-M20996" and when I checked it in the imported SAS data set, I noticed it is read as "1169-M20". It is missing last 3 characters. I set the length of this variable as 32 however it did not help. How can I resolve it?

 

Thanks,

 

2 REPLIES 2
Kurt_Bremser
Super User
From which type of file did you read this? If csv, do NOT use PROC IMPORT, write the DATA step yourself. IF Excel, save the file as csv and do the same.
ballardw
Super User

One of to aspects of using Proc Import is to know that it is a GUESSING procedure. Depending on the file and the information/syntax that you provide to the procedure it can default to setting properties of variables after examining only a very few records. So if the first rows of a variable have the longest value of character variable of 8 characters then a longer value later in the data may only read 8 characters even when longer. You would have to show us the code, preferably from the log to show us how you imported the data.

 

Another bit is that small number of records might mean that the first rows examined for some variables may only have digits and be treated as numbers when later values include characters as well. Those later values would be missing.

 

 

 

Yet another is if you have values that consist of all digits but have leading zeroes that you need then proc import will treat the value as numeric with no leading zeroes.

 

If you are writing proc import code or using one of the widgets you want to set a very large number, ideally the number of rows in the file as the number to examine. This is the GUESSINGROWS option in syntax and the widget may have a box with that or a different name to place a number in.

 

However the leading zero issue will not be resolved by that.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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