BookmarkSubscribeRSS Feed
mcoccia
Calcite | Level 5

Hello all,

 

I am trying to run a matching procedure in my code. I have been stuck on this for a while and cannot seem to find the fix.

 

proc sort data=rmi.zins; by mktcapi; run;
proc sort data=rmi.zpub; by mktcapp; run;

/* Initialize variables */
data rmi.zmatches;
length ticker_symbolp $10 ticker_symboli $10;
do i = 1 to 89;
match = 0;
mkt_diff = .;
do j = 1 to 4024;
/* Check if zpub record has not been matched */
if match = 0 then do;
/* Calculate market cap difference */
mkt_diff_temp = abs(rmi.zins.mktcapi[i] - rmi.zpub.mktcapp[j]);
/* If no previous match or if new match has smaller difference */
if mkt_diff = . or mkt_diff_temp < mkt_diff then do;
mkt_diff = mkt_diff_temp;
ticker_symbolp = rmi.zpub.ticker_symbolp[j];
ticker_symboli = rmi.zins.ticker_symboli[i];
end;
end;
end;
/* Output match */
output;
end;
run;

I have two different datasets 'rmi.zins' and 'rmi.zpub'
Each only have two variables: 'ticker_symboli' and 'ticker_symbolp' respectively 
the second variable is 'mktcapi' and 'mktcapp' respectively

I am POSITIVE that everything is spelt correctly. I tried this in the work library and now I have everything in a different library titled "rmi" hoping this would be the fix.

 

 

 mkt_diff_temp = abs(rmi.zins.mktcapi[i] - rmi.zpub.mktcapp[j]);
                                    ----------------
                                    780
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 780-185: Invalid object or method name.

 

^ this is the error code I get in the log.

 

Help would be much appreciated 

2 REPLIES 2
SASKiwi
PROC Star

Variable names don't have dots in them:

mkt_diff_temp = abs(rmi.zins.mktcapi[i] - rmi.zpub.mktcapp[j]);

Also it looks like you are using array logic (rmi.zins.mktcapi[i]) but you have no array defined in your DATA step. An ARRAY statement is needed.

 

EDIT: you are also missing input data to your DATA step as well. You need to add a SET statement to read in your data.

ballardw
Super User

@mcoccia wrote:


I have two different datasets 'rmi.zins' and 'rmi.zpub'
Each only have two variables: 'ticker_symboli' and 'ticker_symbolp' respectively 
the second variable is 'mktcapi' and 'mktcapp' respectively


 

Other than SORTING those two data sets I do not see any place that rmi.zins or rmi.zpub are actually used.

To use a data set in a data step it must be on a Set, Merge, Update or Modify statement. Which does not occur.

Once a variable is read into the data vector it no longer has any association with the source data set.

 

I would almost guess that this is sort of an attempt to use logic from a spreadsheet except your data description does not have enough columns to match either of your attempted uses (Do i=1 to 89 or Do j=1 to 4024 so where did those magic numbers come from?)

 

If you expect to match records on some values of data variables that have different names then perhaps this belongs in proc sql.

Or provide a small sample of data from both the sets and what you expect as a result.

 

I would also expect that an variable with a name like ticker_symbol or ticker_symbolp might be used to MATCH on but I don't see that anywhere.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 370 views
  • 2 likes
  • 3 in conversation