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.
You're very kind. I'm going for incompetence.
@LaurieF wrote:
You're very kind. I'm going for incompetence.
Just a more polite way of saying the same thing 😉
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...
I expect you're ascribing intention to incompetence.
As a general rule, people have good intentions. But incompetence, coupled with a high energy level, can be a disaster.
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. 🙂
No, you've missed the horrible bit - there's spaces either side of the underscore. _ is a valid SAS variable name.
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
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
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.