BookmarkSubscribeRSS Feed
newbaw
Calcite | Level 5

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!

6 REPLIES 6
Kurt_Bremser
Super User

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.

newbaw
Calcite | Level 5

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!

 

newbaw
Calcite | Level 5

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

 

Shmuel
Garnet | Level 18

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 ?

Kurt_Bremser
Super User

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2149 views
  • 0 likes
  • 3 in conversation