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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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