Modify - Error object failure

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

Modify - Error object failure

[ Edited ]

Hi,

 

I want to update all observations with a condition. If i have a newer date and for the same Tag. I did a search and i may mixed sql and sas.

 

date is in format 05Mar2018 Date9. and Tag is a string

 

data mydata;
	modify mydata adddata;
	by date;
	if (adddata.date ge mydata.date 
AND adddata.Tag eq mydata.Tag) then replace;
run; 

and i have this error:

ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable adddata is not an object.

 

Can i do with this correct by someone or i have other options?

 

Regards,

Aleixo


Accepted Solutions
Solution
‎03-12-2018 05:05 AM
Super User
Posts: 13,542

Re: Modify - Error object failure


Aleixo wrote:

Hi,

 

I want to update all observations with a condition. If i have a newer date and for the same Tag. I did a search and i may mixed sql and sas.

 

date is in format 05Mar2018 Date9. and Tag is a string

 

data mydata;
	modify mydata adddata;
	by date;
	if (adddata.date ge mydata.date 
AND adddata.Tag eq mydata.Tag) then replace;
run; 

and i have this error:

ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable adddata is not an object.

 

Can i do with this correct by someone or i have other options?

 

Regards,

Aleixo


You likely need to have a different variable for the BY statement since you are saying that you want to update date values in the mydata set. It looks like Tag would be the likely candidate. The BY DATE says to match the records on the value of DATE and that appears not to be what you want.

Some example data might help make a better suggestion.

 

When you use things like "adddata.date" in statements other than set, modify, merge, update or data in a datastep .and are not using a Hash object then SAS thinks this is SCL programming. If you reread the syntax examples for MODIFY I think you will not find any that use the SCL syntax.

View solution in original post


All Replies
Solution
‎03-12-2018 05:05 AM
Super User
Posts: 13,542

Re: Modify - Error object failure


Aleixo wrote:

Hi,

 

I want to update all observations with a condition. If i have a newer date and for the same Tag. I did a search and i may mixed sql and sas.

 

date is in format 05Mar2018 Date9. and Tag is a string

 

data mydata;
	modify mydata adddata;
	by date;
	if (adddata.date ge mydata.date 
AND adddata.Tag eq mydata.Tag) then replace;
run; 

and i have this error:

ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 557-185: Variable adddata is not an object.

 

Can i do with this correct by someone or i have other options?

 

Regards,

Aleixo


You likely need to have a different variable for the BY statement since you are saying that you want to update date values in the mydata set. It looks like Tag would be the likely candidate. The BY DATE says to match the records on the value of DATE and that appears not to be what you want.

Some example data might help make a better suggestion.

 

When you use things like "adddata.date" in statements other than set, modify, merge, update or data in a datastep .and are not using a Hash object then SAS thinks this is SCL programming. If you reread the syntax examples for MODIFY I think you will not find any that use the SCL syntax.

Contributor
Posts: 69

Re: Modify - Error object failure

Thank you your answer. you are right.

 

My main problem is the Statement By for partial correlation, because i want to update the date with newdate for a partial correlation of Tag, like final 4 or 5 characters, or in other case for the first 2 words match.

 

It was difficult to do that because the statement By is only for when string match perfectly.

 

Now, you have an example of my data in the other post

PROC Star
Posts: 2,355

Re: Modify - Error object failure

1. The dot notation in data steps is only used for library.table names, or for objects (such as hash tables).

2. It makes no sense to ask for equality (BY statement) and then test for inequality

3. You are after something like this. Modify as required.

 


data MYDATA;
  modify MYDATA ADDDATA(rename=(DATE=NEWDATE));
  by TAG;
  if NEWDATE ge DATE then replace;
run; 
Contributor
Posts: 69

Re: Modify - Error object failure

[ Edited ]

Hi,

 

it is a good ideia your code. But i have a problem in mydata. Some of adddata not exist in mydata. i must change "manually" because is an error of my data.

 

ERROR: The TRANSACTION data set observation does not exist on the MASTER data set.
ERROR: No matching observation was found in MASTER data set.

 

i want to ignore when Tag does not exist in master data.

 

My adddata is something like this:

 

NewDate      Tag
01Mar2018   XXXX-1000
02Mar2017   XXXX-1001
03Mar2017   XXXX-1002
04Mar2017   XXXX-1003
05Mar2017   XXXX-1004
06Mar2017   XXXX-1005
06Mar2017   XXXX-1006
06Mar2017   XXXX-1007 Date Tag 01Jan2017 XXXXY1001 02Mar2015 XXXX-1002 03Mar2018 XXXX-1003 04Mar2016 XXXX-1004 05Mar2018 XXXX-1005 06Mar2017 XXXX-1006 06Mar2018 XXXX-1007

For exame the first mydata is an error because it not suppose to appear "Y". it was suppose to appear "-". It is that cause the SAS error because the program not ignore.

 

For that reason my ideia was test when newTag equal Tag

Super User
Posts: 13,542

Re: Modify - Error object failure


Aleixo wrote:

Hi,

 

it is a good ideia your code. But i have a problem in mydata. Some of adddata not exist in mydata. i must change "manually" because is an error of my data.

 

ERROR: The TRANSACTION data set observation does not exist on the MASTER data set.
ERROR: No matching observation was found in MASTER data set.

 

i want to ignore when Tag does not exist in master data.

 

 

For that reason my ideia was test when newTag equal Tag


Perhaps you should investigate UPDATE instead of MODIFY. The transaction data set for update does not have to have a record for every master.

UPDATE will add records if the BY variable exists in the transaction set but not the master set or new variables.

If you have missing values you want applied to the master use UPDATEMODE=NOMISSINGCHECK.

And if there are multiple transactions for the same master record all are applied.

Contributor
Posts: 69

Re: Modify - Error object failure

Hi,

 

Thank you for your answer. Your idea about UPDATEMODE=NOMISSINGCHECK is correct, perhaps i do not want to overwrite the others observations. When i say overwrite others observations, is to put them for missing values.

 

But i had a problem with statement BY variable because in my situation i do not wanted to change all observations. I wanted to update one variable but with a condition. In my situation a had to create a new table(new collumns) with new values that i want to update because only create observations that i want and not overwrite the others, next merge vertically and then filter the observations that i want.

 

I think it was a stupid idea but worked fine.

 

Regards,

Aleixo

 

Super User
Super User
Posts: 8,105

Re: Modify - Error object failure

I am not sure I totally follow your use case but it sounds like this to me.

You have an existing table and a dataset that might have new records or update records.  If so then it sounds like you just need to use this type of logic that is mentioned in the manual pages.

 

You can use OUTPUT and REPLACE in this example of conditional logic because only one of the REPLACE or OUTPUT statements executes per observation:

 

data master;
   modify master trans; by key;
   if _iorc_=0 then replace;
   else
      output;
run;
Contributor
Posts: 69

Re: Modify - Error object failure

Hi Tom, it is a very good idea that code for modify only observations that i want with a condition.

 

But now i take the opportunity to ask you if it is possible to do that but with the Statement By different. I show you example of my data:

 

NewDate      Tag
01Mar2018   XXXX-1000
02Mar2017   XXXX-1001
03Mar2017   XXXXY1002
04Mar2017   XXXX-1003
05Mar2017   XXXXY1004
06Mar2017   XXXX-1005
06Mar2017   XXXX-1006
06Mar2017   XXXXY1007

Date            Tag
01Jan2017   XXXX-1001
02Mar2015   XXXX-1002
03Mar2018   XXXX-1003
04Mar2016   XXXX-1004
05Mar2018   XXXX-1005
06Mar2017   XXXX-1006
06Mar2018   XXXX-1007

 I can not modify my data BY Tag because the Tag is a "little" diferent. The goal was update for example 1002 and 1004.

 

My solution was create a new table/data and transform Tag different and put them with the right name(transform Y to -) and after that merge vertically and filter repeated Tags by newer Date.

 

Do you understand what i mean?

 

Regards,
Aleixo

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 173 views
  • 0 likes
  • 4 in conversation