BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@Afor910327 wrote:

Hi there,

 

Thank you for your response, SAS is by far the worst language of all, I keep following the tips of everyone here and nothing seems to work at all. 

 

 


You're sorting the data set but using the wrong name after. 

 

You're sorted data set name is 

 

proc sort data=tempsas.ind_conc out=tempsas.ind_conc_sort;
by indCode_id;

 

But in the merge code you're using:

 

ERROR: BY variables are not properly sorted on data set TEMPSAS.IND_CONC.
a=1 indCode_id=41991 datasetPeriod_id=1576 proVal=4.3776485046 Inter=3531.2584548 compensation=2528.7734829 taxes=45.311020873
GOS=-6100.96531 indCode=333517 indCodeDescr=Machine tool (metal forming types) manufacturing indACPSA=ind99
indACPSADescr=All Other Industries FIRST.indCode_id=1 LAST.indCode_id=0 _ERROR_=1 _N_=549
NOTE: MERGE statement has more than one data set with repeats of BY values.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 543 observations read from the data set TEMPSAS.IND_VALUE_ADDED.
NOTE: There were 313 observations read from the data set TEMPSAS.IND_CONC.
WARNING: The data set TEMPSAS.IND_VA_BY_ACPSA may be incomplete.  When this step was stopped there were 545 observations and 11
         variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

Fix your code to use the correct input data set to be merged. If you don't want to deal with presorting the data sets then merge using SQL instead.

View solution in original post

11 REPLIES 11
Jagadishkatam
Amethyst | Level 16

Please sort the tempsas.ind_conc by indCode_id before the merge step to avoid the error.

 

Thanks,
Jag
Afor910327
Obsidian | Level 7

Hi there, 

 

 

Like this, right?

 

proc sort data=tempsas.ind_conc out=tempsas.ind_conc_sort;
by indCode_id;

 

Afor910327
Obsidian | Level 7

Thank you Jag, but I keep getting the same error, time after time...

 

I have attached the latest log, I had done this before and nothing works!

 

Reeza
Super User

You forgot to replace the data set name in the merge with the new sorted data set name.

 

TEMPSAS.IND_CONC

is not ind_conc_SORTED

 


@Afor910327 wrote:

Thank you Jag, but I keep getting the same error, time after time...

 

I have attached the latest log, I had done this before and nothing works!

 



 

PeterClemmensen
Tourmaline | Level 20

Use PROC SORT and sort your data properly before merging.

ballardw
Super User

Any procedure or data step that uses a BY statement will require the data to be sorted by the same variables listed in the same order as the By statement.

 

 

Afor910327
Obsidian | Level 7

Hi there,

 

Thank you for your response, SAS is by far the worst language of all, I keep following the tips of everyone here and nothing seems to work at all. 

 

 

Reeza
Super User

@Afor910327 wrote:

Hi there,

 

Thank you for your response, SAS is by far the worst language of all, I keep following the tips of everyone here and nothing seems to work at all. 

 

 


You're sorting the data set but using the wrong name after. 

 

You're sorted data set name is 

 

proc sort data=tempsas.ind_conc out=tempsas.ind_conc_sort;
by indCode_id;

 

But in the merge code you're using:

 

ERROR: BY variables are not properly sorted on data set TEMPSAS.IND_CONC.
a=1 indCode_id=41991 datasetPeriod_id=1576 proVal=4.3776485046 Inter=3531.2584548 compensation=2528.7734829 taxes=45.311020873
GOS=-6100.96531 indCode=333517 indCodeDescr=Machine tool (metal forming types) manufacturing indACPSA=ind99
indACPSADescr=All Other Industries FIRST.indCode_id=1 LAST.indCode_id=0 _ERROR_=1 _N_=549
NOTE: MERGE statement has more than one data set with repeats of BY values.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 543 observations read from the data set TEMPSAS.IND_VALUE_ADDED.
NOTE: There were 313 observations read from the data set TEMPSAS.IND_CONC.
WARNING: The data set TEMPSAS.IND_VA_BY_ACPSA may be incomplete.  When this step was stopped there were 545 observations and 11
         variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

Fix your code to use the correct input data set to be merged. If you don't want to deal with presorting the data sets then merge using SQL instead.

Afor910327
Obsidian | Level 7

Thank you so much, finally it worked for now!

ballardw
Super User

@Afor910327 wrote:

Hi there,

 

Thank you for your response, SAS is by far the worst language of all, I keep following the tips of everyone here and nothing seems to work at all. 

 

 


Say that after you have done some assembler programming. Smiley Frustrated

 

Spelling is critical in every programming language I know and using the wrong reference seldom yields desired results.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 11 replies
  • 12030 views
  • 4 likes
  • 5 in conversation