BookmarkSubscribeRSS Feed
Davidsas111
Calcite | Level 5

Hi,

I want to know if it's possible to rename a variable with a function.

In particular I need to rename 32 variables with the days past from the today's date. Ex: var1=now(), var2=now()-2 etc.

Thanks for your help.

13 REPLIES 13
ChrisNZ
Tourmaline | Level 20

Try:

rename (or label?) VAR1 to %sysfunc(today(),date9.)

rename (or label?) VAR2 to %sysfunc(putn(%eval(%sysfunc(today())-1),date9.))

rename (or label?) VAR3 to %sysfunc(putn(%eval(%sysfunc(today())-2),date9.))

etc

 

Davidsas111
Calcite | Level 5
Thanks for your help.
Where I Have to Put this code? In the list table advanced filter?
SASKiwi
PROC Star

Why do you want to rename a large number of variables in SAS VA? If you do that you will break any VA reports that use the old variable names. Perhaps if you explain what you are trying to do there might be a better way, possibly by creating calculated items. 

Davidsas111
Calcite | Level 5

Thanks for your answer.

I have to realize a report like the one attached.

EXAMPLE.PNG

I have two buttons that filter yellow columns by 2 variables for the right character variable.

I can't use a cross table because my measures are not numerical.

So I've decided to create a list table with 30 categorical variables (DATE1-DATE30, number of day that I need) that have value:

 

DATE1:

IF ( 'BUTTON 'p = 'VAR 1' )
RETURN 'VAR1_DATE1'n
ELSE 'VAR2_DATE1'n

 

 

DATE2:

IF ( 'BUTTON 'p = 'VAR 2' )
RETURN 'VAR1_DATE2'n
ELSE 'VAR2_DATE2'n

 

etc...

 

 

But now I want to show in the table the current date as label in the list table, and rename date1=now(), date2=now()-1 etc, but I don't know what code use and where use it.

thanks for your help.

 

 

Davidsas111
Calcite | Level 5

Where canI insert that code in VA?

Davidsas111
Calcite | Level 5
If I insert the %sysfunc in the label filelds of a category it dosen't solve it. It writes the %sysfunce litteraly As label
ChrisNZ
Tourmaline | Level 20

Oh this is not good. I swear there was a way to do this. It's been years since I last used VA. What if you create a computed value? Does the macro language get solved?

Davidsas111
Calcite | Level 5

No, the macro language dosen't get solved in a computed value.

I don't know how to do that!

SASKiwi
PROC Star

@Davidsas111  - It would help if you provided a few example rows of your source data. There are probably better ways of transforming your data but since we don't know what it looks like to start with we can't provide any guidance.

 

Also how often do you refresh the data?   

Davidsas111
Calcite | Level 5

I have to refresh datas every day.

I have to transpose a table with "var" char variables, so I can't do it on VA because cross tables can be applied fornumeric variables.

I transpose it on DI but on VA two bottons have to filters data.

Now I have to Rename the category (calculated as I wrote up) with dates.

How can I do it?

Or how can I transpose in VA character variables in a cross table?

Thanks for your help!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 13 replies
  • 1420 views
  • 0 likes
  • 3 in conversation