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

Hi all SAS Users,

 

After playing around for a while, only today, after reading suggestion from @Reeza , I just had a look on PROC EXPAND, which is very efficient and simple to generate the lead and lag variables rather than create the lag or lead variables manually and set condition missing for the first or last observation.

 

I am so surprising why I did not see much people using it (even in some published code in finance. When trying to find the answer, I think: people may prefer the traditional code 

lagx=ifn(first.id,.,lag(x)); /*ifc for character value*/

because this code can be put in one datastep and make the code shorter (one can deal with many things other than creating a lag variable in one datastep).

 

Is it a reasonable thought?

 

Warmest regards.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You may want to peruse the entire SAS product catalog. Depending on what your organization does there can be a number of products that make things much nicer.

 

Once upon a time, in the days of SAS 6.12 I worked with a large government organization that had a license for almost all of the SAS products at the time. Installation disks ran to about 2-and-a-half stack feet. Found some of the ETS procedures very handy for dealing with part of our time series data, IML for a small number of simulation projects, AF and FSP for interface design to data extraction and custom output file creation and writing programs to keep up with the instrument changes at over 60 collection sites, used Proc Loan (ETS) to help analyze options for buying my house, SAS/QC to help with determining if we were having quality issues with collection instrument data, and other stuff.

 

If you have many of these modules it can be surprising just how much of the core of many tasks are available but you need to become familiar enough with the documentation to know where to look and recognize what you need.

Yes, there is a significant $$$ factor. The man hours trying to recreate some of the processes in the various modules with Base SAS and/or macro programming can add up fast and translates into even more money in some cases.

 

 

View solution in original post

4 REPLIES 4
Reeza
Super User
SAS/ETS is an expensive license that isn't that popular. Once you get outside of Base stuff that's a lot more common.
ballardw
Super User

You may want to peruse the entire SAS product catalog. Depending on what your organization does there can be a number of products that make things much nicer.

 

Once upon a time, in the days of SAS 6.12 I worked with a large government organization that had a license for almost all of the SAS products at the time. Installation disks ran to about 2-and-a-half stack feet. Found some of the ETS procedures very handy for dealing with part of our time series data, IML for a small number of simulation projects, AF and FSP for interface design to data extraction and custom output file creation and writing programs to keep up with the instrument changes at over 60 collection sites, used Proc Loan (ETS) to help analyze options for buying my house, SAS/QC to help with determining if we were having quality issues with collection instrument data, and other stuff.

 

If you have many of these modules it can be surprising just how much of the core of many tasks are available but you need to become familiar enough with the documentation to know where to look and recognize what you need.

Yes, there is a significant $$$ factor. The man hours trying to recreate some of the processes in the various modules with Base SAS and/or macro programming can add up fast and translates into even more money in some cases.

 

 

ChrisNZ
Tourmaline | Level 20

 > The man hours trying to recreate some of the processes in the various modules with Base SAS and/or macro programming can add up fast and translates into even more money in some cases.

This does not show on the balance sheet, so bean counters can "save" money' by not licencing products, and then congratulate themselves about all the savings they made.

mkeintz
PROC Star

I agree that PROC EXPAND can often be more straightforward in generating univariate (even multiple univariate) time series - and it can make it easier to generate leads.

 

But there are some characteristics of PROC EXPAND that can make it weaker than the data step alternative:

  1. It's univariate - i.e. you can't get a running series of cross products.  That's a disadvantage when you want to run rolling window regressions.

  2. It only creates data set FILES, not VIEWS.  So, with large datasets, it can be a costly consumer of disk input/output resources.

  3. It can't produce multiple windows sizes in one pass.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

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
  • 4 replies
  • 1238 views
  • 14 likes
  • 5 in conversation