Hi all,
Below is a screenshot of my data. I am having trouble on how to create a column with Previous Year values. As you can see I need the 2016 year value to be in 2017's previous year column. I have tried multiple versions of retain and lag, but I'm not getting what I need still. Any help would be great!
Did prevyear_value = Lag12 (year_value) ; not work? If not show the code you used from the log and describe what is incorrect.
If you are hiding some sort of "group", such as company, that needs to reset then you need to include that information in your description and better instead of picture, that we can't code with, provide some example data in the form of a data step. You only need to provide the relevant variables and dummy data is fine as long as it behaves like your actual data.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.
Did prevyear_value = Lag12 (year_value) ; not work? If not show the code you used from the log and describe what is incorrect.
If you are hiding some sort of "group", such as company, that needs to reset then you need to include that information in your description and better instead of picture, that we can't code with, provide some example data in the form of a data step. You only need to provide the relevant variables and dummy data is fine as long as it behaves like your actual data.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.