Hello friends
I want to ask please what is the best way to retrieve one row before end.
For example:
I want to retrieve the row with mon=1901 (because it is one row before the end)
Data tbl1;
informat start date9. end date9.;
format start date9. end date9.;
input mon start end;
cards;
1812 '21DEC2018'd '21Jan2019'd
1901 '22Jan2019'd '21Feb2019'd
1902 '22Feb2019'd '21Mar2019'd
;
run;
I found the solution
Data tbl1;
informat start date9. end date9.;
format start date9. end date9.;
input mon start end;
cards;
1812 '21DEC2018'd '21Jan2019'd
1901 '22Jan2019'd '21Feb2019'd
1902 '22Feb2019'd '21Mar2019'd
;
run;
data tbl2;
set tbl1 nobs=nobs;
if _n_ =nobs-1 then keep=1;
if keep ne 1 then delete;
run;
I found the solution
Data tbl1;
informat start date9. end date9.;
format start date9. end date9.;
input mon start end;
cards;
1812 '21DEC2018'd '21Jan2019'd
1901 '22Jan2019'd '21Feb2019'd
1902 '22Feb2019'd '21Mar2019'd
;
run;
data tbl2;
set tbl1 nobs=nobs;
if _n_ =nobs-1 then keep=1;
if keep ne 1 then delete;
run;
Like this, you read only one record of the set:
data junk;
point = max(1, nobs - 1);
set sashelp.class point=point nobs=nobs;
output; stop;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.