I am attempting to implement the following code:
https://support.sas.com/rnd/app/stat/examples/SurveyPoisson/surveypoisson.htm
I copied the code from the SAS program tab here:
https://support.sas.com/rnd/app/stat/examples/SurveyPoisson/sas.html
However, I am encountering errors at section 4 of the code, after running the two macros. (See attached log, with errors highlighted in yellow.) Note also the code sections highlighted in aqua; I added these PROC SORT statements to address errors with the 'by' statements encountered in subsequent syntax.
I have attempted the solution noted in the following post (running the 3a and 3b macros separately):
I have attempted to run sections 3a and 3b, separately, in sequence; and also to run through section 3a, then comment out this section, and run again from section 1 through section 3b. However, I continue to encounter the error. Any assistance would be appreciated. Thank you.
Hello @lsr0820,
I ran both versions of the code -- version 1: using section 3a, version 2: using section 3b -- successfully in two separate SAS sessions to avoid any conflicts between the two versions.
Your log indicates that the PROC APPEND steps contained in macro jkloop duplicated some of the datasets, in particular dataset JKDF (which thus has got 7600 instead of 3800 observations), because they appended new data to datasets existing from a previous run or from a section of the code that should not have been run before (in the same SAS session). This must have caused the sort issues (like duplicating 1, 2, 3 to 1, 2, 3, 1, 2, 3). So you do not need to insert your own PROC SORT steps. Just run the original code either using section 3a or section 3b in a new SAS session.
There's one (actually irrelevant) warning in the log due to an inconsistency between macro jkloop and the code before. To avoid the warning, you can delete the data step
data FullSample;
set FullSample;
rename estimate=estimate0;
run;
close to the end of macro jkloop. It is redundant because of the RENAME= dataset option to the same effect which was applied to dataset FullSample when it was created by an ODS OUTPUT statement earlier in the code.
Hello @lsr0820,
I ran both versions of the code -- version 1: using section 3a, version 2: using section 3b -- successfully in two separate SAS sessions to avoid any conflicts between the two versions.
Your log indicates that the PROC APPEND steps contained in macro jkloop duplicated some of the datasets, in particular dataset JKDF (which thus has got 7600 instead of 3800 observations), because they appended new data to datasets existing from a previous run or from a section of the code that should not have been run before (in the same SAS session). This must have caused the sort issues (like duplicating 1, 2, 3 to 1, 2, 3, 1, 2, 3). So you do not need to insert your own PROC SORT steps. Just run the original code either using section 3a or section 3b in a new SAS session.
There's one (actually irrelevant) warning in the log due to an inconsistency between macro jkloop and the code before. To avoid the warning, you can delete the data step
data FullSample;
set FullSample;
rename estimate=estimate0;
run;
close to the end of macro jkloop. It is redundant because of the RENAME= dataset option to the same effect which was applied to dataset FullSample when it was created by an ODS OUTPUT statement earlier in the code.
Running the sections in two separate SAS sessions solved the issue! Thanks very much for the help.
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.