Help using Base SAS procedures

Error in first. and last. statement

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 92
Accepted Solution

Error in first. and last. statement

data ttt (drop=value period);

set testing;

by region;

if first.region and last.region then output ttt;

else output =duplicate;

run;

I get the error message that variable duplicate is uninitialized. PLease advice.


Accepted Solutions
Solution
‎10-24-2014 06:15 AM
Super User
Posts: 7,783

Re: Error in first. and last. statement

And drop the erroneous equal sign Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 7,783

Re: Error in first. and last. statement

That's very simply because "duplicate" is not in the input data set.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 298

Re: Error in first. and last. statement

It is not due to FIRST. or LAST.

Place the data set names in the Output like:

data ttt (drop=value period) duplicate;

Solution
‎10-24-2014 06:15 AM
Super User
Posts: 7,783

Re: Error in first. and last. statement

And drop the erroneous equal sign Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 92

Re: Error in first. and last. statement

Just one more thing - as you mentioned duplicate in  the data step statement, would it create a new dataset which will capture other values excluding the first and the last obs of the group.

🔒 This topic is solved and locked.

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

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