diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index 2025734210eff681bbbb3c44e3168e3da6367ea8..a81627bc2d21a3f6b411151a447d693ae9022961 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -532,15 +532,17 @@ end
 if ~isempty(dataset_)
     options_.nobs = dataset_.nobs;
     if options_.endogenous_prior 
-        if dataset_info.missing.no_more_missing_observations<dataset_.nobs-10
-            fprintf('\ndynare_estimation_init: There are missing observations in the data.\n')
-            fprintf('dynare_estimation_init: I am computing the moments for the endogenous prior only\n')
-            fprintf('dynare_estimation_init: on the observations after the last missing one, i.e. %u.\n',dataset_info.missing.no_more_missing_observations)
-        else
-            fprintf('\ndynare_estimation_init: There are too many missing observations in the data.\n')        
-            fprintf('dynare_estimation_init: The endogenous_prior-option needs a consistent sample of \n')
-            fprintf('dynare_estimation_init: at least 10 full observations at the end.\n')
-            error('The endogenous_prior-option does not support your missing data.')
+        if ~isnan(dataset_info.missing.number_of_observations) && ~(dataset_info.missing.number_of_observations==0) %missing observations present
+            if dataset_info.missing.no_more_missing_observations<dataset_.nobs-10
+                fprintf('\ndynare_estimation_init: There are missing observations in the data.\n')
+                fprintf('dynare_estimation_init: I am computing the moments for the endogenous prior only\n')
+                fprintf('dynare_estimation_init: on the observations after the last missing one, i.e. %u.\n',dataset_info.missing.no_more_missing_observations)
+            else
+                fprintf('\ndynare_estimation_init: There are too many missing observations in the data.\n')
+                fprintf('dynare_estimation_init: The endogenous_prior-option needs a consistent sample of \n')
+                fprintf('dynare_estimation_init: at least 10 full observations at the end.\n')
+                error('The endogenous_prior-option does not support your missing data.')
+            end
         end
     end
 end