Help using Base SAS procedures

ERROR: There was a problem with the format so BEST. was used.

New Contributor
Posts: 3

ERROR: There was a problem with the format so BEST. was used.

[ Edited ]



I encountered a weired situation. I imported a dataset from CSV files, and named it MIDAS. Most of its variables have format BEST12. and informat 12.


I processed it as usual and when I tried to merge it to another dataset, with "if a and b" specified, the resultant dataset has 0 observation. This is unexpected, because I mannually checked that there are many observations with the same "by" variable values. 


So I suspected that it was because the format. I tried to use this to remove all format:


proc datasets lib=work memtype=data nolist;
modify MIDAS;
attrib _all_ label=' ';
attrib _all_ format=;
attrib _all_ informat=;


However, it does not work. Then I tried to remove format of dates and the rest using

"format date YYMMDDN8.;
informat date YYMMDD6.;"


This time it seems to be working. But once when I opened the reformated dataset, I repeatedly hear "beep" and in the log I got many many "ERROR: There was a problem with the format so BEST. was used."


What should I do to make the merge work? Thanks!

Super User
Posts: 10,874

Re: ERROR: There was a problem with the format so BEST. was used.

The actual SAS format applied to variables will never have an effect on SET or Merge.


You mention errors. It helps to provide the actual errors and code from the log. Paste into a code box using the forum {i} menu icon.


I suspect from " I imported a dataset from CSV " that you actually used Proc Import or the import wizard or similar task. Each time you use Proc Import SAS is guessing from the contents of the file what type and format the variables should have. I suspect that you actually have some variables that are character instead of numeric in the different sets. This can happen if the first few rows of the data are missing for a variable then SAS will set it to character.


What is best with CSV files is to run the import one time. SAS will generate data step code that you can copy from the log into an editor and save. Check that the variable types, informats and lengths are as you need. Save the program. Then the next time you read a CSV of the same format you change the infile information and the data set name. All of the variables will have the same name, type, length and format.

It helps to add variable labels as well.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation