BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Naveen1111
Calcite | Level 5

Hi All,

 

I have been trying to use like operator with _(underscore). Could someone tell why the below mentioned program didn't work? However, if I use % , getting the required output.

 

proc sql;
create table navin as select * from sashelp.cars
where model like 'M_X';
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @Naveen1111 

 

It seems that there are some leading blanks in the Model variable:

proc sql;
select * from sashelp.cars
where model like ' M_X';
quit;

/*or*/

proc sql;
select * from sashelp.cars
where strip(model) like 'M_X';
quit;

 

Test:

proc sql;
select tranwrd(model,' ','x') as _model from sashelp.cars
where strip(model) like 'M_X';
quit;

Capture d’écran 2020-06-10 à 20.16.54.png

 

Best,

View solution in original post

2 REPLIES 2
ed_sas_member
Meteorite | Level 14

Hi @Naveen1111 

 

It seems that there are some leading blanks in the Model variable:

proc sql;
select * from sashelp.cars
where model like ' M_X';
quit;

/*or*/

proc sql;
select * from sashelp.cars
where strip(model) like 'M_X';
quit;

 

Test:

proc sql;
select tranwrd(model,' ','x') as _model from sashelp.cars
where strip(model) like 'M_X';
quit;

Capture d’écran 2020-06-10 à 20.16.54.png

 

Best,

Naveen1111
Calcite | Level 5

thanks.