DATA Step, Macro, Functions and more

Is stop statement necessary?

Accepted Solution Solved
Reply
Super Contributor
Posts: 271
Accepted Solution

Is stop statement necessary?

[ Edited ]

The two prgrams meant to create a macro variable &_name_. Is stop statment redundant in first progam as program will terminate eventually anyway?

 

data _null_;
	set sashelp.class;

	if _n_=1 then
		do;
			call symput('_name_',name);
			stop;
		end;
run;


data _null_;
	set sashelp.class;

	if _n_=1 then
		do;
			call symput('_name_',name);
		end;
run;

%put &_name_;

 


Accepted Solutions
Solution
‎02-29-2016 05:36 PM
Respected Advisor
Posts: 3,799

Re: Is stop statement necessary?

Posted in reply to SAS_inquisitive

Stopping when the work is done makes it look like you know what you're doing.

View solution in original post


All Replies
Respected Advisor
Posts: 3,799

Re: Is stop statement necessary?

Posted in reply to SAS_inquisitive

STOP; prevents the data step from doing nothing for the other 18 records in SASHELP.CLASS.

Super Contributor
Posts: 271

Re: Is stop statement necessary?

Posted in reply to data_null__
@ data_null_, thanks. I have seen people coding both ways.
Solution
‎02-29-2016 05:36 PM
Respected Advisor
Posts: 3,799

Re: Is stop statement necessary?

Posted in reply to SAS_inquisitive

Stopping when the work is done makes it look like you know what you're doing.

Super User
Super User
Posts: 7,039

Re: Is stop statement necessary?

Posted in reply to SAS_inquisitive

Actually if you have the STOP statement you do not need the IF statement.

data _null_;
  set sashelp.class;
  call symput('_name_',name);
  stop;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 284 views
  • 4 likes
  • 3 in conversation