BookmarkSubscribeRSS Feed
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;



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



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


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.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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
  • 2 in conversation