BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

data live_account;
merge live_account(in=a) purge(in=b) plan(in=c);
if a and ~b;
by account_no;
;

if card_type in ("PL" "TU") then do;
if plan_num=60000 then output;
end;
else output;
run;

is output here a dataset name or it just means only

if card_type in ("PL "TU") then if plan_num =60000 then output to dataset live_account?

otherwise output everything that is not card_type in ("PL "TU") into dataset live_account?

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@HeatherNewton wrote:

 

data live_account;
merge live_account(in=a) purge(in=b) plan(in=c);
if a and ~b;
by account_no;
;

if card_type in ("PL" "TU") then do;
if plan_num=60000 then output;
end;
else output;
run;

is output here a dataset name or it just means only

if card_type in ("PL "TU") then if plan_num =60000 then output to dataset live_account?

otherwise output everything that is not card_type in ("PL "TU") into dataset live_account?

 


Whenever you have actual SAS code, you can run the code and see the results. SAS will answer your questions, and do it more quickly than asking questions here. And unlike my answers, which are not correct 100% of the time, you know you will get the correct answer from SAS 100% of the time (maybe even more than 100% of the time!)

--
Paige Miller
Kurt_Bremser
Super User

It's always astonishing to see the crazy ways people come up with to make code less understandable, and less maintainable.

data live_account;
merge live_account(in=a) purge(in=b) plan(in=c);

Don't do this. If, during development, the data step has a semantic mistake, dataset live_account will be destroyed, forcing you to recreate it.

if a and ~b;

It is preferable to use the mnemonic NOT in place of the tilde character; some characters may not be available on all platforms, or text processing software tends to replace them with UTF equivalents. A keyword is immune to that.

if card_type in ("PL" "TU") then do;
if plan_num=60000 then output;
end;
else output;

A little Boolean transformation simplifies this:

if card_type not in ("PL" "TU") or plan_num = 60000 then output;

Reading the documentation (Maxim1!) will quickly tell you what the OUTPUT Statement does.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 444 views
  • 1 like
  • 3 in conversation