BookmarkSubscribeRSS Feed
spa5263
Calcite | Level 5

I am trying to create a variable (RET2) that will give me the return (variable RET) of the month following the quarterly index (quart_index). I currently have the following:

data portfolio; set portfolio;
	RET2 = (ret(month(quart_index)) + 1);

 

The error that SAS is giving me is:

1607  data portfolio; set portfolio;
1608      RET2 = (ret(month(quart_index)) + 1);
                  ---
                  68
ERROR 68-185: The function RET is unknown, or cannot be accessed
5 REPLIES 5
PaigeMiller
Diamond | Level 26

Please show us a portion of your data set.

--
Paige Miller
Doc_Duke
Rhodochrosite | Level 12

It appears that RET is a variable and you are using it as a function.

Reeza
Super User
That isn't valid SAS code, so my question is what did you expect it to do, and how is your data structured?
spa5263
Calcite | Level 5

I need the code to create a new column in my result that shows the return of the stock for the month after the quarter. 

Reeza
Super User

Which depends on the structure of the data. For example, looking up a value within the same row is different than looking for a value in a different row. Therefore without your data structure we cannot help you.

 

Here are instructions on how to provide sample data as a data step:
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...


@spa5263 wrote:

I need the code to create a new column in my result that shows the return of the stock for the month after the quarter. 


 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 2047 views
  • 0 likes
  • 4 in conversation