DATA Step, Macro, Functions and more

File semaforo

Reply
New Contributor
Posts: 3

File semaforo

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!

Super User
Posts: 7,811

Re: File semaforo

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: File semaforo

Posted in reply to KurtBremser

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!

 

Super User
Posts: 7,811

Re: File semaforo

Just do

data _null_;
file "name_of_semaphore_file";
put 'OK';
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
New Contributor
Posts: 3

Re: File semaforo

Posted in reply to KurtBremser

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

 

Trusted Advisor
Posts: 1,572

Re: File semaforo

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 ?

Super User
Posts: 7,811

Re: File semaforo

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 6 replies
  • 431 views
  • 0 likes
  • 3 in conversation