DATA Step, Macro, Functions and more

Is stop statement necessary?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 234
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,777

Re: Is stop statement necessary?

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,777

Re: Is stop statement necessary?

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

Regular Contributor
Posts: 234

Re: Is stop statement necessary?

@ data_null_, thanks. I have seen people coding both ways.
Solution
‎02-29-2016 05:36 PM
Respected Advisor
Posts: 3,777

Re: Is stop statement necessary?

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

Super User
Super User
Posts: 6,502

Re: Is stop statement necessary?

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
  • 283 views
  • 4 likes
  • 3 in conversation