Help using Base SAS procedures

Proc Summary/Mean

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Proc Summary/Mean

Proc summary data = LIB_TRN.FFMSUB_SELECTED_1804 nway missing;
  by gpnr crms_org_id;
  var prov_num;
  output out= LIB_TRN.FFMSUB_SELECTED_AGG_1804(drop = _Smiley Happy
  sum= maxid(prov_num(gpnr crms_org_id reporting_period db_filialnummer
       db_kontonummer ccdb_id kategorie gpname gbmerker
       nachrichtlich))=;
quit;

WARNING: Variable gpnr already exists on file LIB_TRN.FFMSUB_SELECTED_AGG_1804.
WARNING: Variable crms_org_id already exists on file
         LIB_TRN.FFMSUB_SELECTED_AGG_1804.
WARNING: The duplicate variables will not be included in the output dat
         the output statement number 1.

 

Please help me to remove this warning .


Accepted Solutions
Solution
‎06-07-2018 01:59 AM
Super User
Posts: 6,777

Re: Proc Summary/Mean

The problem your code creates is that you are using these variables for two different purposes:  GPNR and CRMS_ORG_ID.  They are both part of the BY statement and part of the MAXID clause.

 

I can't see a reason to keep them in the MAXID clause, when they are already part of the BY statement.

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: Proc Summary/Mean

Please help me reAD ySmiley HappyR code .  Easy to read code is not optional, it is key for anyone else looking at it.  Several tools are made available for to post code, use the code window - its the {i} above the post area, this keeps code formatting and doesn't put smiley faces in for instance.  Also, avoid coding in mixed case, thats not how you read a book.

 

You can try the autoname and autolabel options.  Basically the warning is telling you that the variable being created from the sum already exists as a variable in the dataset, so you need to give it another name.  The autoname should add sum_ to the name.

proc summary data=lib_trn.ffmsub_selected_1804 nway missing;
  by gpnr crms_org_id;
  var prov_num;
  output out=lib_trn.ffmsub_selected_agg_1804 
  sum=maxid(prov_num(gpnr crms_org_id reporting_period db_filialnummer
                     db_kontonummer ccdb_id kategorie gpname gbmerker
                     nachrichtlich))= / autoname autolabel;
quit;

 

Occasional Contributor
Posts: 17

Re: Proc Summary/Mean

Thanks for you suggestion.I will keep in mind from now onwards. Yes I did try autoname and autolabel but it created new variable gpnr2 and crms_org_id2. May be I have gpnr and crms_org_id in "by" statement also. Anyway I removed it from maxid(variable list) now it is fine. Thanks.
Solution
‎06-07-2018 01:59 AM
Super User
Posts: 6,777

Re: Proc Summary/Mean

The problem your code creates is that you are using these variables for two different purposes:  GPNR and CRMS_ORG_ID.  They are both part of the BY statement and part of the MAXID clause.

 

I can't see a reason to keep them in the MAXID clause, when they are already part of the BY statement.

Occasional Contributor
Posts: 17

Re: Proc Summary/Mean

Posted in reply to Astounding
Yes. I did removed it from MAXID clause and it worked fine. Thank you.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 172 views
  • 0 likes
  • 3 in conversation