BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lsr0820
Calcite | Level 5

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):

https://communities.sas.com/t5/Statistical-Procedures/Poisson-Regressions-for-Complex-Surveys/td-p/3...

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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.

lsr0820
Calcite | Level 5

Running the sections in two separate SAS sessions solved the issue! Thanks very much for the help.

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
  • 2 replies
  • 382 views
  • 0 likes
  • 2 in conversation