I am trying to put some dates such as '01jan1999'd as column name, but I can't work it out, is it possible?
If yes I would like to rename adjacent columns from '01jan1999'd to '01jan2009'd, is it possible without writing alll the names?
alternatively I am thinking about putting the dates as records in a column and then doing a transpose,
but also here is there a fast method to put these names, like if it were a drag in excel?
thanks in advance
SAS enumerated variable lists can be incremented by 1 or -1 only as far as I know. You seem to want an arbitrary increment in this case MONTH. That's find but it does not work with enumerated variable lists.
If it were me I would keep the months/dates/ whatever as rows as long as possible. Then when you need to have the months/dates/whatever become variables transpose to variables and LABEL the variables in a way that communicates the details of the data that you have placed in the meta data. PROC TRANSPOSE statement IDLABEL will allow you to assign labels to the new variables using data.
Using a name prefix list you don't even have to know how many.
First of all, why do you want them as columns at all? As you seem to already experienced yourself, it's not very convenient, neither for data manipulation programming nor reporting.
You say you can't work it. What have you tried? Showing som code might help.
You could achieve this by setting VALIDVARNAME = ANY, and use the name literal when specifying your column names.
I know that it's not convenient, but in this analysis is very helpful to know the exact month, e.g. 01march2002 instead of month47.
a trial would be like this, but it does not work
data base(rename=(month1-month180= '01jan1999'n to '01jan2009'n));set base;run;
Seems easier to transpose your data, and the apply your date transformation on colmn values instead.
SAS enumerated variable lists can be incremented by 1 or -1 only as far as I know. You seem to want an arbitrary increment in this case MONTH. That's find but it does not work with enumerated variable lists.
If it were me I would keep the months/dates/ whatever as rows as long as possible. Then when you need to have the months/dates/whatever become variables transpose to variables and LABEL the variables in a way that communicates the details of the data that you have placed in the meta data. PROC TRANSPOSE statement IDLABEL will allow you to assign labels to the new variables using data.
Using a name prefix list you don't even have to know how many.
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.
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.