BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dhana18
Obsidian | Level 7

Good morning,

i am stocked with this problem, could you please help me?

 

ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10357151
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10358360
WARNING: 2 BY groups omitted due to earlier errors.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your BY group has duplicate entries. You usually have three options:

 

1. Remove duplicates

2. Consolidate entries - add a count or sum variables

3. Add a variable to your BY or ID statement that would uniquely identify each entry.

 


@Dhana18 wrote:

Good morning,

i am stocked with this problem, could you please help me?

 

ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10357151
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10358360
WARNING: 2 BY groups omitted due to earlier errors.


 

 

View solution in original post

14 REPLIES 14
Amir
PROC Star

Hi,

 

Please post a copy of the log that includes the SAS code along with error / note messages.

 

 

Regards,

Amir.

Dhana18
Obsidian | Level 7
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=0357151
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=0358360
WARNING: 2 BY groups omitted due to earlier errors.
Kurt_Bremser
Super User

Maxim 3, know your data.

Within a by group, values in the id variable must not appear more than once. Determine what to do with those values before you transpose.

Reeza
Super User

Your BY group has duplicate entries. You usually have three options:

 

1. Remove duplicates

2. Consolidate entries - add a count or sum variables

3. Add a variable to your BY or ID statement that would uniquely identify each entry.

 


@Dhana18 wrote:

Good morning,

i am stocked with this problem, could you please help me?

 

ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10357151
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=10358360
WARNING: 2 BY groups omitted due to earlier errors.


 

 

novinosrin
Tourmaline | Level 20

Please show us your data sample, your required output, your code and the log

ballardw
Super User

The procedure option LET on the proc statement will allow multiple values for an ID variable. However the results are typically not what you want.

 

Example data and desired output may help resolve your actual issue.

Dhana18
Obsidian | Level 7

Still having the same problem, spent all day today figuring this out,please help.

ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=0210357151
ERROR: The ID value "HIV_COMBO" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
EVENT_ID=0210358360
WARNING: 2 BY groups omitted due to earlier errors.

novinosrin
Tourmaline | Level 20

We requested

 

"Example data and desired output may help resolve your actual issue."

Dhana18
Obsidian | Level 7

My data is very complex with thousands of records.  same person can visit the clinic many times in a year and at one visit the person can have many different tests.

for example

 

data test;
input patient_id event_id test site $ results$;
DATALINES;
1 01 300 U N 
1 01 700 O P
1 01 700 P N
1 01 900 V N
1 01 700 R P
2 02 300 V P
2 01 900 B P
;
RUN;

For example, I want to find out  any 700 tests in a visit / event in a given period of time with p or n result.

Reeza
Super User

Ok, is that your input? What would you expect as output, exactly?

If this does not reflect the situations you were referring to and generating the errors, please modify your input data to ensure the issues you're encountering are in the sample data. 

 

To answer the question you posed is relatively trivial, except you mention a given period but don't actually have any time/date variable in your data. See the code below, which assumes a date variable. The output is also in the data set want.

 


@Dhana18 wrote:

 

For example, I want to find out  any 700 tests in a visit / event in a given period of time with p or n result.



proc freq data=test;
where test=700 and results in ('P', 'N');
*assume you have some date variable;
table date_event / out=want;
format date_event yymmn6.;
run;
Dhana18
Obsidian | Level 7

Thank you Reza,

Here is sample data. i would like to count each group of test with result for example  NAAT ONLY (NAATR,NAATP, NAATP, NAATG), CULTURE ONLY (CULP,CULG, CULR) and BOTH NAAT and CULTURE and EITHER NAAT or CULTURE.  what logic should i use?

EVENT_IDHIV_GEENIOHIV_COMBOPMNSGNIDGNEDHCGCULPCULGCULRNAATUNAATPNAATGNAATR
44      P PNP P
46 N       NN  
47 N   N   NN  
51 NPNN    NN  
52 N       NN  
53         NN  
55 N   N N NN  
56 N       N   
57 N    N NNN N
58 N       NN N
60 N    NN NN  
61         NN  
62 NPNN    NN  
64 N       N   
65 N       N   
66 NPNN    N   
67 N       NN N
68     N   NN N
70 N   P   N   
72 NPNN    N   
73 N       NN  
Dhana18
Obsidian | Level 7

Hi,

I have this sample data. I would like to get each group of test for example NAAT only CULT only Both NAAT and CULTURE, either CULTURES or NAAT. what logic should i use?

 

EVENTID HIV PMNS CULP CULG CULR NAATR NAATP NAATU NAATG

44            N       P           N       N           N         P         N           P           N

45                     N                     N           P          N         N          N

46            N                      N                                N                     P           N

47                      N                                   N                                        

48           N                       N                    N            N           N                 P

Reeza
Super User

What do the P/N mean? Do they affect the results?

 

Calculate two more indicator variables and then use those instead.

 

CUL=0; NAAT=0;
if missing(coalescec(culp, culg, culr)) then CUL=1;
if missing(coalescec(NAATR, NAATP, NAATU, NAATG)) then NAAT=0;

*optional;
CUL_OR_NAAT = max(CUL, NAAT);
CUL_AND_NAAT = CUL*NAAT;



And then the summaries once those variables are created:

 

proc means data=have N MEAN SUM;
var CUL NAAT CUL_OR_NAAT CUL_AND_NAAT;
ods output summary=want
run;

 


@Dhana18 wrote:

Hi,

I have this sample data. I would like to get each group of test for example NAAT only CULT only Both NAAT and CULTURE, either CULTURES or NAAT. what logic should i use?

 

EVENTID HIV PMNS CULP CULG CULR NAATR NAATP NAATU NAATG

44            N       P           N       N           N         P         N           P           N

45                     N                     N           P          N         N          N

46            N                      N                                N                     P           N

47                      N                                   N                                        

48           N                       N                    N            N           N                 P




hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 3082 views
  • 0 likes
  • 6 in conversation