Hi Guys,
what is the end= options
in datastep can you give examples on this option
Regards,
ANAND
There could be many ways to use the end option, one of thing of end option is it identifies the last observation like in the example below
data want;
set sashelp.class end=eof;
if eof then flag=1;
run;
There could be many ways to use the end option, one of thing of end option is it identifies the last observation like in the example below
data want;
set sashelp.class end=eof;
if eof then flag=1;
run;
Thank u for your valuable support
See the Data Step Set Statement Documentation Page and look at the END= Option.
Also, run the code below and check the result.
data have;
do x=1 to 10;
output;
end;
run;
data want;
set have end=end;
lr=end;
run;
proc print data=want;
run;
Thank you very much
A little more complicated example:
data _null_; set work.rename end=LastName; if _n_ = 1 then do; Call execute ("Proc datasets library=&OutDataLib nodetails nolist;"); Call execute ("modify &RenamedData;"); Call execute ("rename ") ; end; Call execute(catx(' ',name,' = ',newname)) ; if LastName then do; Call execute (";") ; Call execute ("quit;"); end; run;
The data set work.rename has a list of variable names that needed to be standardized so contains a Name and Newname variable.
This code creates a call to proc datasets to change the names in place with the modify statement. So we need 1) the start of proc datasets with the library and data set names (strored in macro variables) and the start of a Rename block of code, 2) all of the name to newname pairs and 3) the End option comes in to generate the end of the Rename block and the call to Proc Datasets ;
Sometimes the End option can be used to create a cntlin dataset for Proc Format to set the "other" value options for a format as you need a bit more than a simple list of start and label values.
With the Report Writing Interface for the data step the END option could be used to write what ever might appear at the bottom of any generated text.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.