Hi, I am working on a credit risk database using SAS Enterprise Guide 4.3. I have 40 monthly files with the same variables, of which two are of interest for this issue: one variable is a binary one called 'bad', who takes the value 1 when an account is in default and 0 otherwise, and another one called 'account-exposure'. What I need to do is retain the value of the account_exposure for each account_number at the moment of default, i.e. when the bad variable turns from 0 to 1 from one month to the next. The primary key in all the datasets is the account_number, and I have compiled a dataset with all the bad=1 from the last available month. (these are the accounts that need to be checked) I am a bit stuck as I would basically need to look at two consecutive datasets at a time to compare the values of 'bad' and retain the account_exposure for each account_number if bad(dataset_month1)=1 and bad(dataset_month0)=0 but I am not sure how to do that going through all 40 datasets. The name of all datasets are something like blablabla_yyyymm, and have tought of something like below but I am not too familiar with macros: %macro default(data); Proc sql; Create table defaultflag as Select &data.account_number &data.account_exposure Substr(put(&data), length(put(&data))-3, 4) as default_date /*how do I transform the dataset name into a character string?*/ from &data Where &data.bad=0 and &data.bad=1; /*this condition should be formulated in another way*/ Quit; %mend default; Any help on the above or any other ideas would be much appreciated!!
... View more