BookmarkSubscribeRSS Feed
jan_t_lagen
Calcite | Level 5

In my project I need to iteratively sample some portfolio data and run this through a model. To reduce computation time in the model I have created a key that makes use of the symmetry and clumps all similar entities in the portfolio together. When trying without iterating this is easily done by some group by statements. This is roughly what i'm doing:

 

proc surveyselect data=tot

method=srs n=10000 out=port_in noprint;

run;

 

Proc Sql;

Create table port as 

select distinct KEY_ID, ID_1, ID_2, sum(w) as w_s

from port_in

group by KEY_ID

;quit;

 

where KEY_ID is a unique number for all combinations of ID_1 and ID_2.

 

I know that I can call on these inside my proc iml but what i want to know if this is the most efficient way of achieving what i want or if using only iml functions is better. So what i want to achieve is this:

 

1 Sample a portfolio from a larger one

2 Reduce its size by summing and only getting distinct values

3 Insert 2 into a model

4 Repeat

1 REPLY 1
Rick_SAS
SAS Super FREQ

Since PROC SURVEYSEELCT supports the STRATA statement and PROC SQL supports the GROUP BY statement, it seems that you could do this outside of IML. The result would be a data set that contains samples for each portfolio.

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 643 views
  • 0 likes
  • 2 in conversation