Buongiorno, vorrei creare un file semaforo a seguito dell'esecuzione di un job.
Questo job come risultato finale esporta un file csv giorno per giorno e mi serve che un file semaforo(vuoto) verifichi che questo csv creato non sia vuoto.
C'è un modo? Grazie!
You might get more feedback if you posted your question in English.
If do have an inkling that I might be able provide some help regarding semaphore files and their use, especially on UNIX platforms.
Thank you Kurt. So I translate in english my question:
Every day there is a scheduled job (in Unix machine) that export , in a specific location, a csv file that contains some information.
After the job produce that csv file, I need that the job produce also a semaphore file (the format is not important, but its name must contain the word OK) wich inform that the csv file is not empty.
How can I do this? What code I can write in the job? Thank you!
Just do
data _null_;
file "name_of_semaphore_file";
put 'OK';
run;
Thank you Kurt, but I think that in this way the procedure only create a file with the 'OK' information, but there is no kind of control on the csv file that the job creates before the SEM file. How can I implement this control (that help the user to understand that the csv file is not empty)?
Thank you
You can add number of observations exported to the CSV file.
To answer the question - how to do it - please display your code for exporting:
is it by proc export or by data step or by sql ?
If you just want to check for a certain number of records processed in an export, you can do that:
%let nrecords=0;
* necessary, because the following data step will have no iteration at all if dataset indataset is empty;
data _null_;
file "outfile" /* options */;
set indataset /* options */ end=done;
put
/* variables */
;
if done then call symput('nrecords',strip(put(_n_,best.)));
run;
%macro write_sem;
%if "&nrecords" ne "0" %then %do;
data _null_;
file "semfile";
put 'OK';
run;
%end;
%mend;
%write_sem;
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.