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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 471 views
  • 1 like
  • 3 in conversation