So what fails here is a SQL join.
Your join creates a cartesian product, which can easily overwhelm your storage before the WHERE is applied. Consider replacing the SQL with a DATA step; a range of dates can easily be stored in an ARRAY through which you loop with a DO.
To help you with code, we need usable example (fake) data in data steps with datalines (DO NOT SKIP THIS!) and the expected resulting dataset.
@Yanni_C wrote:
2. I want to split the dataset based on the different observations in 'characteristics', but I don't want to name the dataset using the name of the observations, I want to use dataset1, dataset2, dataset3,...
Then just name them that way.
Here is the step from the accepted answer:
%do i=1 %to &c;
data &&typ&i;
set have ;
Just change it to generate DATASET1, .... instead
%do i=1 %to &c;
data dataset&i;
set have ;
If your table was not big.
data have;
input cusip_id Name $10. date_issue :ddmmyy10. type $10.;
format date_issue ddmmyy10.;
datalines;
10343452 Zingas 01/04/2016 bench
10343489 Stephanie 01/04/2014 main
10343445 Olivia 01/04/2012 main
10343456 Amstel 01/04/2011 bench
10343457 KEO 01/04/2017 main
;
run;
proc freq data=have noprint;
table type/out=level nopercent;
run;
data _null_;
set level;
call execute(catt('data data_',type,';set have;if type="',type,'";run;'));
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.