BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
progster
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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.

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

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.

Data never sleeps
progster
Fluorite | Level 6

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;

LinusH
Tourmaline | Level 20

Seems easier to transpose your data, and the apply your date transformation on colmn values instead.

Data never sleeps
data_null__
Jade | Level 19

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.

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!

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
  • 4 replies
  • 4178 views
  • 3 likes
  • 3 in conversation