BookmarkSubscribeRSS Feed
gra_in_aus
Quartz | Level 8

I have started using DS2 programming and have hit a snag.  I have tried to convert a data step into DS2, however I am not 100 % sure that the procedure is handling the _error_ :

 

proc ds2;
data spdework.dsn1 (overwrite=yes) spdework.dsn2 (overwrite=yes);
  dcl char brand country ;
  dcl double _error_ ;
  method init();
  end;
  method run();
 SET spdework.aami_rif_1 (rename=( nvar_pre=nvar));

 IF gdp>0 and content>0 then
  country='US';
 else if gdp>0 then
  country='UK';
 else if content>0 then
  country='EU';
 else
  PUT 'errors';

 if nvar>0 then
  nvar=1;
 brand='Brand X  ';
 set {select distinct customer from spdework.dsn3};
 if _error_ then
  output spdework.dsn1;
 else
  output spdework.dsn2;

  end;
  method term();
  end;
enddata;
run; quit;

 

In data step I was getting 606490 in DS2 112810 obs.  Any help would be appreciated.

 

Thanks

1 REPLY 1
BrunoMueller
SAS Super FREQ

Hi

 

The _ERROR_ is an automatic variable within the DATA Step. You do not have the same variable available in DS2.

 

From the doc:

Automatic Variables

_ERROR_
is 0 by default but is set to 1 whenever an error is encountered, such as an input data error, a conversion error, or a math error, as in division by 0 or a floating point overflow.
 
I assume there is some data type conversion, this triggered the _ERROR_ to be set to 1, whereas this does not happen in DS2.
 
Bruno

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 761 views
  • 0 likes
  • 2 in conversation