If your code throws errors you need to share them as we can't tell what they might be.
Run the code, go to the log and copy the text of the submitted code along with all notes, messages and errors. On the forum open a text box by clicking on the </> icon above the message window and paste the copied text.
The text box is important because the message windows on the forum will reformat pasted text and many of the errors will cause SAS to place diagnostic characters in the log. The reformatted text will typically move those diagnostics so that the position cannot be determined.
I suspect one of your errors is the INPUT statement. To use an Input that way there has to be text to read by the program. The text could be in an external file, which would require an INFILE statement to identify it, or a DATALINES block where the data step contains the text to read. If you want to use data from an existing data set then you use a SET statement to identify the data set.
I am guessing that you actually want : Set qul; as the data set you just sorted.
To use the First.variable and Last.variable constructs there must be a BY statement using the variable name.
The First.variable return true/false numeric values of 1/0. So your Yrdif call is attempting to use 1 and 0, which would be 2Jan1960 and 1Jan1960 respectively (SAS dates are the number of days from 1Jan1960).
So that indicates you likely want something like (AFTER you add the by statement): If first.vdate then firstv_date=vdate;
Similar for the last date.
You will need to do similar to Retain and calculate a difference for the scores.
And only calculate the year difference after you have the last date.
This will make no sense to SAS:
IF change - THEN score = 'better';
ELSE IF change + THEN score = 'Worse';
ELSE IF change 0 THEN score = 'NoChange';
You have to provide a comparison operator such a = > or < (EQ GT LT GE (greater than or equal) LE ) and a value
Maybe
If change < 0 then score = 'Better';
else if change > 0 then score= 'Worse';
else if change = 0 then score= 'No Change';
Caveat: your score variable will have a length of 6 characters and will truncate "No Change" to 6 as well. When using character variables it is a good idea to explicitly assign a length large enough to hold the longest expected value before use:
Length score $ 9;
... View more