BookmarkSubscribeRSS Feed
RafiRahi
Fluorite | Level 6

The variable APP_ID - is it character variable? If it is then the below code is working in my 9.2 version of base SAS to find any number which has the value '61738495' in the string -

WHERE APP_ID CONTAINS '61738495' ;

If it the above code does not work then please let me know if the variable APP_ID is numeric.

Thanks.

Rafi

Rafi Rahi
podarum
Quartz | Level 8

The error I get with CONTAINS is this :

7989: Invalid operand for the CONTAINS operator. The operand must have a Period data type that is comparable to the other operand.

Patrick
Opal | Level 21

So what are the data types of the variables in your 2 tables. They must be character in order for a LIKE or CONTAINS to work.

podarum
Quartz | Level 8

They're both numeric.

podarum
Quartz | Level 8

APP_ID is numeric.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then you would need to (Oracle sytax again) cast the numeric into a character string to use the like % syntax.  In SAS it would be put(variable,best.).

podarum
Quartz | Level 8

Basically I have a field in my local data that is chopped (eg.  '61738495') and am trying to match it to another field in my data warehouse that is not chopped (eg.  '6005617384952') .  Have been using

on INDEX (TRIM(a.APP_ID_DW), TRIM(put(b.APP_ID_FILE, 12.))) > 0   that didn't work, I get an error like Function TRIM requires a character expression as arguement 1.. Even if I make APP_ID_FILE a character or numeric.


RafiRahi
Fluorite | Level 6

Could you please try this -

WHERE PUT( APP_ID, 8.) CONTAINS  '61738495' ;

Rafi Rahi
podarum
Quartz | Level 8

Got this error :

3706 : Syntax error : Data type "APP_ID" does not match a Defined Type name.

RafiRahi
Fluorite | Level 6

Duh! Now I am not sure how to resolve it! Smiley Sad

Rafi Rahi
pp2014
Fluorite | Level 6

Try

where cats(APP_ID)  like '%61738495%';

podarum
Quartz | Level 8

same error as before (using cats(APP_ID) like

3706 : Syntax error : Data type "APP_ID" does not match a Defined Type name.

stat_sas
Ammonite | Level 13

As your both variables are numeric you need to convert both of them in char

data have;

input APP_ID_DW APP_ID_FILE;

datalines;

61738495 6005617384952

;

proc sql;

select * from have

where put(APP_ID_FILE,best16.) contains strip(put(APP_ID_DW,best16.));

quit;

podarum
Quartz | Level 8

Awesome.. this worked..Smiley Happy

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!

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
  • 28 replies
  • 1791 views
  • 1 like
  • 8 in conversation