BookmarkSubscribeRSS Feed
kristelSAS
Calcite | Level 5

Hi,

 

My supervisor made me a macro to look at the logistic regression of multiple climate factors on several days combined on the possiblity of sows aborting (sumverwerp5).

The macro will give a log output in txt and a result output in csv. I get both these outputs, however, the csv output contains only dots and no actual data.

My supervisor however, does get the right data. How is this possible while using the same macro (I only adjusted the file locations and names to my own sets, but in practice, we have completely the same sets)?

Due to the corona virus, my supervisor and I are unable to meet, so communication and helping is a bit hard now... But I am desperate, as I still have deadlines to make!

 

In added my macro in the attachments. (I am sorry that some variables/words are in Dutch and probably not understandable for most of you). 

 

Thank you for helping me!

9 REPLIES 9
Patrick
Opal | Level 21

If the exactly same code works for your superior but not for you then it's most likely about different data sources (your "sets"). The SAS code alone won't provide us any information.

 

What we need is the SAS log - please run the code using options MPRINT and MSGLEVEL=I

 

And if you want to inspect the log first for yourself: Look out for Notes & Warning messages talking about variables not initialized or missing generated and the like.

 

We're also working from home in my office. We use mainly Skype for Business to communicate and share screens (you can even give someone control over your screen or have multiple people in a meeting) but there are also other tools out there. You must have "something" in your company as email and phone calls alone are not sufficient.

kristelSAS
Calcite | Level 5
I downloaded my supervisors file again and started working on a 'clean sheet'. Luckely now I have some answers. My supervisor will email his output this afternoon to make sure we have the same output! I also emailed him which changes I made to the dataset, so he could validate those and also change them in his dataset
ChrisNZ
Tourmaline | Level 20

Compare your boss's log and yours for the same run, and you'll see where things start diverging and going pear-shaped..

kristelSAS
Calcite | Level 5
I did have some warnings in my logs, but send them to him and he stated that those were common warnings and that I did not have to worry about it (I'm a beginner with SAS). Furthermore, I downloaded my supervisors file again and started working on a 'clean sheet'. Luckely now I have some answers. My supervisor will email his output this afternoon to make sure we have the same output!
ChrisNZ
Tourmaline | Level 20

>those were common warnings and that I did not have to worry about 

These warnings are a sign of sloppy programming.

 

A good program does not generate warnings or notes such as those mentioned here (uninitialized variables, etc).

 

Tom
Super User Tom
Super User

Make sure your are both using the same version of SAS.  There are some minor differences in how some PROC behave in different versions.

 

Another thing to check is the setting of the VALIDVARNAME option.   That can cause some steps to generate different variable names.  Make sure both of you are using the same setting.

 

kristelSAS
Calcite | Level 5
I made sure we have the same program. I downloaded my supervisors file again and started working on a 'clean sheet'. Luckely now I have some answers. My supervisor will email his output this afternoon to make sure we have the same output!
ballardw
Super User

Please post code into a code box, not an attachment. Then everyone will have easy access to the code. Copy from your editor and paste into a box opened on the forum with </> or "running man" icon. Same for any Log entry you share.

OPTIONS NOCENTER;

*rename data directory;
LIBNAME klaas "/folders/myfolders/klaas";

%macro delfile (DS);
  %if %sysfunc (exist (&DS)) %then %do;
    proc sql no print; drop table &DS; quit;
  %end;
%mend delfile;

%macro analysis;
TITLE "Output of temp_in";
%delfile(ORCI);   %delfile(COEF); %delfile(HOSM);
ODS OUTPUT CLOddsWald=ORCI;
ODS OUTPUT ParameterEstimates=COEF;
ODS OUTPUT LackFitChiSq=HOSM;
PROC LOGISTIC DATA=analysis;
   CLASS bedrijf (REF='1') parity (REF='1') Weeknr (REF='11')/PARAM=REF;
   MODEL sumverwerp5 (EVENT='1')= bedrijf parity Weeknr Climate_parameter /CLPARM=WALD CLODDS=WALD LACkFIT;
RUN;     
%mend analysis;

%macro append1;
   %delfile(combilogit);
   DATA varname; Climate_parameter="temp_in"; OUTPUT; RUN;
   DATA COEF; SET COEF;
      WALD_p=ProbChiSq; 
      DROP ProbChiSq WaldChiSq _ESTTYPE_;
   RUN;
   DATA INTERC; OddsRatioEst=.; LowerCL=.; UpperCL=.; OUTPUT; RUN;
   DATA ORCI; SET INTERC ORCI; DROP effect unit; RUN;
   DATA HOSM; SET HOSM; HOSMER_p=ProbChiSq; DROP DF NGroups ChiSq ProbChiSq; RUN;
   DATA combilogit; MERGE varname COEF HOSM ORCI; RUN;
    PROC APPEND BASE=collect_logit DATA=combilogit; RUN;
%mend append1;

%macro select;
   %delfile(collect_logit);
   %DO I=1 %TO 27;
      DATA analysis;
      SET work.all38;
      ARRAY ar1[27] meantemp_in1-meantemp_in27; *change variable name;
      name1=vname(ar1[&i]);
      name1a=substr(name1,1,length(name1));
      CALL SYMPUT('name1', name1a);
      Climate_parameter=ar1[&i];
      RUN;
      %analysis;
      %append1;
   %END;
%mend select;
*switch off screen output, makes it slow;
ODS PREFERENCES;
ODS HTML CLOSE;
ODS LISTING CLOSE;
ODS RESULTS=OFF;
PROC PRINTTO LOG='/folders/myfolders/klaas/log.txt' NEW;RUN;
*invoke macro series;
%select; quit;
*switch on screen output;
ODS HTML;
ODS RESULTS=ON;PROC PRINTTO; RUN;
TITLE ;

*write final file as Excel readable csv file;
ODS CSV FILE='/folders/myfolders/klaas/output.csv';
PROC PRINT DATA=collect_logit;RUN;
ODS CSV CLOSE;




*Just to check if the macro works correctly;
PROC LOGISTIC DATA=work.all38;
   CLASS bedrijf (REF='1') parity (REF='1') Weeknr (REF='11') /PARAM=REF;
   MODEL sumverwerp5 (EVENT='1')=bedrijf parity Weeknr meantemp_in1/LACKFIT; *replace MAXco2_in;
RUN;

The first place I see a likely issue is the Libname at the top. Would I be wrong in saying that does not point to the same location your supervisor has data? If not, how did you get that data you need into that library or your WORK library?

 

 

 

kristelSAS
Calcite | Level 5
I will do that the next time, thanks for your comment! I am very new in the SAS language, so do not understand most of it, but I am trying my hardest haha. I downloaded my supervisors file again and started working on a 'clean sheet'. Luckely now I have some answers. My supervisor will email his output this afternoon to make sure we have the same output!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 9 replies
  • 704 views
  • 1 like
  • 5 in conversation