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!
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.
Compare your boss's log and yours for the same run, and you'll see where things start diverging and going pear-shaped..
>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).
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.
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?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.