BookmarkSubscribeRSS Feed
LaurieF
Barite | Level 11

Actually I know what it does, and I can guess what the intention was as well, but these variables are used throughout a whole process. Sadly, infuriatingly, it is quite hard to untangle. Hold on to your hats:

id_fda= cats(of id _ year_fda); 
id_lda= cats(of id _ year_lda);

As a hint, id, year_fda and year_lda are defined variables from the previous step. But the other variable, ahem, _, is not.

 

The cat family of functions is quite good at casting numeric variables to character, without warning messages and internal generation of inefficient code. As long as it knows about the variables from the dataset vector. When that variable (ahem - _) is not defined it gets a little upset.

 

The intention was, we believe, to strip and concatenate the id and year_xxx variables together, with a separator of '_'. If _ was defined as character with the contents of '_', it would have worked. But instead (I feel unclean) its referenced as a numeric variable with a missing value. This gets cast from numeric to character so that we now have id and year_xxx stripped and concatenated with a #$>?@#$ '.' in between.

 

Someone get me a beer, please. I've seen some rubbish in the last forty years of SAS programming, but this takes the cake.

11 REPLIES 11
Reeza
Super User
My guess is it was supposed to be a hyphen instead of an underscore and got missed in the error checking process.
LaurieF
Barite | Level 11

You're very kind. I'm going for incompetence.

Reeza
Super User

@LaurieF wrote:

You're very kind. I'm going for incompetence.


Just a more polite way of saying the same thing 😉

 

 

ChrisNZ
Tourmaline | Level 20

Yes this is some confused code!

I wonder why the coder used the list operator OF instead of a comma between variable names. OF makes it compulsory that everything else is a variable.

Maybe we should have a community for "Creatively-Rabid-Abuse-of-Programming Code". Or maybe we should not... 

 

Astounding
PROC Star
A wild guess....

The _ was originally a double dash indicating a list of variables such as

ID -- year_fda

One text editing system converted two narrow dashes to one wide dash. Then at a later point, a user noticed that a wide dash is an illegal name for a variable, and changed it to an underscore.
LaurieF
Barite | Level 11

I expect you're ascribing intention to incompetence.

Astounding
PROC Star

As a general rule, people have good intentions.  But incompetence, coupled with a high energy level, can be a disaster.

novinosrin
Tourmaline | Level 20

How about the possibility of : suffix to make it a list for OF to take effect?

id_fda= cats(of id_year_fda:); 

 

Btw, Beer does sound very nice. 🙂

LaurieF
Barite | Level 11

No, you've missed the horrible bit - there's spaces either side of the underscore. _ is a valid SAS variable name.

Kurt_Bremser
Super User

You can only search for places further down the line where those two new variables are used, and try to infer from the use what they should contain.

 

You might find

  • they are never used and can safely be removed
  • they are created with an incorrectly set length
  • that it is actually expected that an underline separates the values, but in fact does not matter
  • the dot instead of the underline causes an undetected problem and incorrect end results (or y'all were simply lucky)
  • somebody already programmed around the dot caused by the missing numerical value

To me, such things are a sign that a re-thinking of the process and a re-coding is in order. SAS programs usually profit from a complete rewrite every ten years or so.

 

Edit: fixed several typos caused by hypocaffeinosis

LaurieF
Barite | Level 11

As I've pointed out before, there's only one variable I was concerned with, and that was the underscore one. I've been working at this site for a year, and I've constantly been struck by the lack of facility in reporting analysts who have been called on to do ETL work for which they are not equipped.

 

Occam's razor - you're overcomplicating things. It's lack of skill, backed up by lack of training, backed up by getting the wrong person to do the job.

 

PS You don't want me doing maths…

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
  • 1054 views
  • 7 likes
  • 6 in conversation