PROC FSEDIT is a product of SAS/FSP software for full-screen interactive data entry. This procedure provides a user-friendly interface for entering new and updating old observations in a dataset.
The data entry screen invoked by PROC FSEDIT can be modified using the SCL, SAS Component Language for developing interactive SAS applications.
SCL code consists of parts with headings followed by semicolons (e.g., init:, main:, term: ) that run at different time points of screen appearance, existence and termination, respectively.
Error checking can happen during these stages, depending on the error, but most commonly in the main: section.
Now, the question:
How can I use SCL to modify the behavior of PROC FSEDIT screen so that it 1) checks if a user is entering a duplicate id (that is already in the dataset), 2) outputs an error message about it and 3) prevents updating the dataset with entries that have duplicate id values?
array a 10 { 1 2 3 4 5 6 7 8 9 10 };
fseinit:
control ALLCMDS;
return;
init:
if id EQ '' then do;
CURSOR id;
end;
else do;
if input(id, 2.) in a then put 'ID is in array a.';
else put 'ID is not in array a.';
protect id;
end;
return;
main:
erroroff _ALL_;
if id EQ ' ' then do;
erroron id;
_msg_ = 'ERROR: EMPTY ID FIELD';
return;
end ;
cmd = upcase(lastcmd());
if (cmd EQ 'ADD') then do;
UNPROTECT id;
_msg_ = 'NO DUPLICATE IDS, PLEASE';
end;
return;
term:
return;