BookmarkSubscribeRSS Feed
PrimeDougR
Fluorite | Level 6

I have a SAS 9.4 program that outputs an Excel workbook with 2 tabs.  When I run the program it works correctly.  When run by a scheduled CRON script, however, only the first tab is included.

 

Is there a difference in the way the SAS program runs when it is run manually vs. when it is called and run by a CRON script?

 

5 REPLIES 5
LinusH
Tourmaline | Level 20

And even more important, post your logs.

Data never sleeps
PrimeDougR
Fluorite | Level 6

Here is the essence of my program:

 

libname sasprod "/sas_shared/data";

PROC SQL;

CREATE TABLE work.DataTable1 AS

Select
  Field1,
  Field2,
  Field3,
  Field4,
  Field5
from sasprod.Table1
where Field1 = 'P'
and (Field2 = 'ABC' or Field2 = 'DEF'))
);

QUIT;

data _variables_;
D = date() - 1;
call symput('D',put(D,MMDDYY10.));
D_yyyymmdd = (year(D) * 10000) + (month(D) * 100) + day(D);
call symput('D_yyyymmdd',D_yyyymmdd);
file_name = "/sastmp/sas_shared/output/TestFile &D_yyyymmdd..xlsx";
call symput('file_name',trim(file_name));
run;

proc export data = work.DataTable1
   outfile="&file_name"
   dbms=xlsx
   replace;
   sheet="Detail";
run;

proc sql;
create table work.Table1Summary as
(Field2, count(Field3) as Count3, Sum(Field4) as Sum4, sum(Field5) as Sum5
from work.DataTable1
group by Field2);
run;

proc export data = work.Table1Summary
   outfile="&file_name"
   dbms=xlsx
   replace;
   sheet="Summary";
run;

 

PrimeDougR
Fluorite | Level 6

This question has been resolved.  It actually involved SAS columns that were using "field name"n references.

 

When I added

            options validvarname=any;

 

this resolved the problem.  I still don't know why it worked without that option when running the SAS program, but failed when running it via a CRON script.  But at this point, the fact that it now runs both ways is all that matters.

 

Kurt_Bremser
Super User

Validvarname = any is usually set for GUI environments, where badly structured data with stupid column names coming from external sources is quite common. Typically, SAS is used in a more controlled environment, so this option is not the default.

IMHO, people coming up with such column names should be sentenced to keep at least 1LD from computers.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 887 views
  • 0 likes
  • 3 in conversation