BookmarkSubscribeRSS Feed
GeorgeSAS
Lapis Lazuli | Level 10

Hello everyone,

If i want keep name start with 'D'. the code below works,but how if I want keep the name end with "y"?or second letter is "o"? Is there any similar operator like "=: "to do this in data step?(data step only)

data test;

  input name $;

  cards;

  John

  Diana

  Diane

  Sally

  Doug

  David

  ;

  run;

  data test;

  set test;

  if name =: 'D';

  run;

  proc print;

  run;

Thanks

4 REPLIES 4
data_null__
Jade | Level 19
data test;
   set test;
   if name =: 'D' or char(name,2) eq 'o' or char(name,length(name)) eq 'y';
  
run;
Babloo
Rhodochrosite | Level 12

data test;

  input name $;

  cards;

  John

  Diana

  Diane

  Sally

  Doug

  David

   ;

  run;

  proc sql;

create table want as select * from test where name like  '%y' or  name like '%o%' ;

quit;

  

  proc print;

  run;

Ksharp
Super User
data test;
  input name $;
  cards;
  John
  Diana
  Diane
  Sally
  Doug
  David
  ;
  run;
  data want;
   set test;
   if prxmatch('/^D|^[a-z]o|y$/i',strip(name));
run;

Xia Keshan

Message was edited by: xia keshan

Jagadishkatam
Amethyst | Level 16
data test;
   set test;

  if substr(compress(lowcase(name)),2,1)='o' or                substr(compress(lowcase(name)),length(name),1)='y' or

     substr(compress(lowcase(name)),1,1)='d' ;

run;

Thanks,
Jag

Thanks,
Jag

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 740 views
  • 0 likes
  • 5 in conversation