BookmarkSubscribeRSS Feed
mfisher
Fluorite | Level 6

Proc distance allows the use of an ID statement with a BY statement, as long as ID is character and they are sorted in the same order within BY.

The attached code "Distance with character year as ID" works fine (year is prefixed with Y).

The second attached code,  "Distance with numeric year as ID" (no prefix, but year is input as character) returns the error:

"ERROR: The ID variable must have the same values in the same order in each BY group."

  Any ideas why?

5 REPLIES 5
PGStats
Opal | Level 21

I noticed the same thing. I guess this restriction simplifies the generation of column names in the distance matrix and makes the names more previsible. The error message could be a tad clearer though.Smiley Wink

PG

PG
mfisher
Fluorite | Level 6

PG,

Here's an interesting twist--if you have only 1 BY group, the code works.  Columns are named with an underscore before the year, e.g., _2008.

Mark

PGStats
Opal | Level 21

Very interesting indeed. So, what might have been construed as a feature is thus an error, since it makes the procedure behaviour inconsistent. Your finding might explain the error message as well. I think that the DISTANCE procedure, when it gets to the second BY-group, checks the ID values against the variable names established during the first BY-group, and finds that they don't match (i.e. '2004' against '_2004'), thus the message "The ID variable must have the same values in the same order in each BY group." Seems like they simply omitted to translate ID values into variable names before doing the comparison.

PG

PG
mfisher
Fluorite | Level 6

I agree.

Shall I formally report this to SAS, or is posting here good enough?

PGStats
Opal | Level 21

As far as I know, you must report the bug to Tech Support, but you can refer them to this discussion for the details. - PG

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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