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.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 743 views
  • 0 likes
  • 2 in conversation