There are rules that determine what names are allowed. Normally, a variable name of 202110 is not allowed (and really is a bad idea to have calendar information in variable names anyway).
Either you are seeing the variable label when you look at the data set (are you?) or the data set was created with
options validvarname=any;
in which case you can refer to a variable name as '202110'n (note the quotes and the suffix which is the letter n) and so you can refer to it as
Data want (keep= _name_ "&yyyymm"n);
Do yourself a favor and turn this data set into a long data set (instead of a wide data set) where the month is the value of the variable named MONTH, and then almost all of your programming becomes much much much much much much much much easier muchly.
There are rules that determine what names are allowed. Normally, a variable name of 202110 is not allowed (and really is a bad idea to have calendar information in variable names anyway).
Either you are seeing the variable label when you look at the data set (are you?) or the data set was created with
options validvarname=any;
in which case you can refer to a variable name as '202110'n (note the quotes and the suffix which is the letter n) and so you can refer to it as
Data want (keep= _name_ "&yyyymm"n);
Do yourself a favor and turn this data set into a long data set (instead of a wide data set) where the month is the value of the variable named MONTH, and then almost all of your programming becomes much much much much much much much much easier muchly.
Let me correct something you said.
@AJ_Brien wrote:
Someone else is creating the base dataset so I couldn’t update the variable names. But adding ‘n’ After the variable name totally worked.
you don't add 'n' with quotes
you put the variable names in quotes and then append the letter n
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Save $200 when you sign up by March 14!
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.