Return to Snippet

Revision: 6340
at May 17, 2008 13:40 by webonomic


Initial Code
/*Example*/
data two;
  set one;
  if x ^= . then goto out;
  x = (y + z) / 2;
  out: if x > 20 then output;
run;


/*Example with data*/
data class;
   input name $ 1-8 sex $ 11 age height weight;
   select (name);
	 when ('Alice') do;
	   goto Alice;
	 end;
	 when ('Becka') do;
	   goto Becka;
	 end;
	 when ('Gail') do;
	   goto Gail;
	 end;
  end;
Alice: x=4;
   return;
Becka: x=5;
   return;
Gail: x=6;
   return;
datalines;
Alice     F 13 56.5  84.0
Becka     F 13 65.3  98.0
Gail      F 14 64.3  90.0
run;

Initial URL
http://jaredprins.squarespace.com/blog/2008/5/26/sas-flow-control-the-goto-statement.html

Initial Description
You can use the goto statement to have SAS process statements in some other part of your program, by providing a label followed by a colon before the statements you wish to jump to. Label names follow the same rules as variable names, but have a different name space. When a labeled statement is encountered in normal processing, it is ignored.

Initial Title
SAS goto statement

Initial Tags


Initial Language
SAS