BookmarkSubscribeRSS Feed
afiqcjohari
Quartz | Level 8
	data want1;
		set have;
		where cPOSMode in ('07','90');
	run;
	data want2;
		set have;
		where cPOSMode in ('02') 
			and cToken is not null
			and cPvder is not null
			and idTReq is not null;
	run;
       
        data want1; set want1 want2;run;

How do I simplify above 3 data steps into 1?

4 REPLIES 4
Reeza
Super User

Combine WHERE clauses into 1 step using an OR

afiqcjohari
Quartz | Level 8
data want;
set have;
where cPOSMode in ('07','90') or (cPOSMode in ('02') and cToken is not null and cPvder is not null and idTReq is not null);
;run;
Reeza
Super User

@afiqcjohari wrote:
data want;
set have;
where cPOSMode in ('07','90') or (cPOSMode in ('02') and cToken is not null and cPvder is not null and idTReq is not null);
;run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26
data want;
  set have;
  if cposmode in ('07','90') or
     cposmode='02 and (ctoken ne "" and cpvder ne "" and idtreq ne "") then output;
run; 

Note, I assume the three varaibles are character as you don't say.  Also, use one casing for your code, mixing casing makes code harder to read.

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!

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