BookmarkSubscribeRSS Feed
catkat96
Obsidian | Level 7

Hi everyone, I'm currently doing a basic training in SAS but unfortunately wasn't provided with the solutions, and there is one problem that I am unsure if I solved properly. 

 

I uploaded a sample of the data I'm working with.

I learnt sorting, tables, merging, transposing, summarizing, proc freq, formats and macros, so you know around what level I am. 

 

The task was to "produce a breakdown of defaulted customers vs non-defualted customers who took a loan in 2018 by demographic.
All available demographics should be used produce a file that gives a % in defualt for each subcategory in each wider category."

 

This was what I came up with:

 

data data_2018;
	set data.master(where=('01JAN2019'd>Disbursal_date>='01JAN2018'd));
run;

%MACRO dofreq2 (var);
	PROC freq DATA=data_2018;
		table &var.*latest_status / out=freq2_&var.;
	RUN;
%MEND;

%dofreq2(age_band);
%dofreq2(residential_status);

In your opinion, is this the right way to solve this (given the tools i've learned)?

I wasn't sure how to make a table with JUST the "default" percentages. Also, I wasn't sure if they meant the percentages of Default per age band (for example) out of the different percentages all status for all age bands have (which is what I did) or to take an age band as 100% and then get the percentage of defaults over that band only. How do you see it? 

 

EDIT: here is the sample of data

 

Disbursal_dateLatest_Statusage_bandresidential_statusEmployment_statusloan_purposeMISSING_POSTCODE
05/30/2016Completed41-60Homeowner (Joint MorFull TimeHome ImprovementN
07/25/2018Active41-60Homeowner (Mortgage)Full TimeHome ImprovementN
11/14/2018Completed41-60Homeowner (Joint MorFull TimeHome ImprovementN
05/13/2010Completed41-60Homeowner (Joint MorFull TimeHome ImprovementN
02/10/2020Active41-60Homeowner (No MortgaSelf EmployedHome ImprovementN
12/15/2014Completed41-60Homeowner (Mortgage)Full TimeHome ImprovementN
03/29/2016Completed41-60Homeowner (Joint MorFull TimeHome ImprovementN
03/10/2020Active60+RentingFull TimeHome ImprovementN
05/31/2018Completed60+Homeowner (No MortgaPart TimeHome ImprovementN
11/27/2018Active60+Homeowner (Mortgage)Full TimeHome ImprovementN
12/11/2017Active60+Living with ParentsFull TimeHome ImprovementN
07/18/2016Completed60+Homeowner (Mortgage)Full TimeHome ImprovementN
09/19/2016Completed60+Homeowner (Joint MorFull TimeHome ImprovementN
10/15/2018Completed60+Homeowner (Joint MorFull TimeHome ImprovementN
04/01/2018Active60+Homeowner (Joint MorFull TimeHome ImprovementN
01/23/2012Completed60+Homeowner (No MortgaPart TimeHome ImprovementN
06/24/2016Completed60+RentingFull TimeHome ImprovementN
03/21/2014Completed60+Homeowner (Joint MorFull TimeHome ImprovementN
05/08/2017Active18-21Homeowner (Joint MorFull TimeOtherN
09/30/2015Default18-21Homeowner (Mortgage)Full TimeOtherN
07/10/2017Active18-21Homeowner (Mortgage)Full TimeOtherN
09/25/2015Completed18-21Homeowner (Joint MorFull TimeOtherN
05/15/2019Late18-21Homeowner (Mortgage)Full TimeOtherN
08/15/2012Completed18-21RentingFull TimeOtherN
09/05/2018Active22-30Homeowner (Joint MorFull TimeOtherN
09/11/2013Completed22-30Homeowner (Mortgage)Full TimeOtherN
10/31/2016Completed22-30Homeowner (Joint MorFull TimeOtherN
06/19/2019Active22-30Living with ParentsFull TimeOtherN
02/19/2018Active22-30Homeowner (Joint MorFull TimeOtherN
04/12/2017Completed22-30RentingFull TimeOtherN
07/09/2018Completed22-30RentingPart TimeOtherN
03/06/2017Completed22-30Living with ParentsFull TimeOtherN
04/07/2015Default22-30Homeowner (Joint MorFull TimeOtherN
10/28/2017Completed22-30Homeowner (No MortgaUnemployedOtherN
12/21/2015Completed22-30RentingFull TimeOtherN
02/19/2020Active31-40Homeowner (Mortgage)Full TimeOtherN
01/24/2020Active31-40Homeowner (Joint MorFull TimeOtherN
01/09/2017Completed31-40Homeowner (No MortgaFull TimeOtherN
09/03/2018Active31-40RentingFull TimeOtherN
05/28/2012Completed31-40Living with ParentsFull TimeOtherN
10/12/2017Completed31-40Homeowner (Joint MorFull TimeOtherN
02/05/2018Active31-40Homeowner (Joint MorFull TimeOtherN
08/30/2011Completed31-40Homeowner (No MortgaPart TimeOtherN
08/22/2019Active31-40Homeowner (Mortgage)Full TimeOtherN
11/01/2019Active31-40Homeowner (Joint MorFull TimeOtherN
09/22/2018Active31-40Homeowner (No MortgaFull TimeOtherN
05/14/2016Active31-40Homeowner (Mortgage)Full TimeOtherN
11/14/2019Active31-40Homeowner (Mortgage)Full TimeOtherN
06/28/2016Completed31-40Homeowner (No MortgaFull TimeOtherN
09/12/2019Active31-40Homeowner (Joint MorFull TimeOtherN
09/13/2017Completed31-40RentingFull TimeOtherN
10/16/2015Completed31-40Homeowner (No MortgaFull TimeOtherN
02/05/2020Active31-40Homeowner (Mortgage)Full TimeOtherN
09/20/2018Completed31-40RentingSelf EmployedOtherN
05/15/2019Completed31-40Living with ParentsFull TimeOtherN
02/22/2011Completed31-40RentingFull TimeOtherN
05/15/2019Completed31-40Homeowner (Joint MorFull TimeOtherN
02/20/2019Completed31-40Homeowner (Joint MorContractingOtherN
07/02/2018Late31-40RentingPart TimeOtherN
08/14/2017Active31-40RentingContractingOtherN
07/08/2016Completed31-40Homeowner (Joint MorPart TimeOtherN
11/17/2019Active31-40Homeowner (Mortgage)Part TimeOtherN
02/17/2016Completed31-40Homeowner (Joint MorFull TimeOtherN
06/10/2019Default31-40Living with ParentsPart TimeOtherN
03/05/2018Late31-40Homeowner (Joint MorFull TimeOtherN
05/06/2019Active31-40RentingFull TimeOtherN
03/06/2018Late31-40Homeowner (Mortgage)Full TimeOtherN
06/10/2013Completed31-40Homeowner (Mortgage)Full TimeOtherN
11/03/2015Completed41-60Homeowner (Mortgage)Part TimeOtherN
01/10/2012Completed41-60Homeowner (Joint MorFull TimeOtherN
06/10/2014Completed41-60Homeowner (Mortgage)Part TimeOtherN
10/08/2019Completed41-60Homeowner (Mortgage)Part TimeOtherN
02/17/2009Completed41-60RentingPart TimeOtherN
08/22/2016Completed41-60Homeowner (No MortgaFull TimeOtherN
04/20/2017Completed41-60Homeowner (Joint MorFull TimeOtherN
07/04/2018Active41-60Living with ParentsFull TimeOtherN
12/03/2018Active41-60Homeowner (Joint MorFull TimeOtherN
10/29/2015Completed41-60RentingFull TimeOtherN
06/06/2014Completed41-60Homeowner (Joint MorFull TimeOtherN
12/19/2016Completed41-60Homeowner (Joint MorFull TimeOtherN
10/25/2017Active41-60RentingFull TimeOtherN
04/23/2018Active41-60Homeowner (No MortgaFull TimeOtherN
06/24/2015Default41-60RentingFull TimeOtherN
11/06/2016Completed41-60Homeowner (Joint MorFull TimeOtherN
06/30/2017Completed41-60RentingFull TimeOtherN
09/16/2016Completed41-60Homeowner (No MortgaFull TimeOtherN
10/06/2016Active41-60RentingFull TimeOtherN
06/22/2019Completed41-60Homeowner (Joint MorFull TimeOtherN
11/22/2019Active41-60Homeowner (Joint MorFull TimeOtherN
11/28/2016Completed41-60Homeowner (Joint MorPart TimeOtherN
07/23/2019Active41-60Homeowner (Mortgage)Self EmployedOtherN
11/28/2019Completed41-60Homeowner (No MortgaFull TimeOtherN
06/23/2015Active41-60Homeowner (Mortgage)Full TimeOtherN
07/27/2018Active41-60RentingUnemployedOtherN
07/27/2019Completed41-60Living with ParentsFull TimeOtherN
01/31/2020Active41-60Homeowner (No MortgaFull TimeOtherN
12/27/2017Completed41-60Homeowner (Mortgage)Full TimeOtherN
09/17/2018Active41-60Homeowner (Mortgage)Full TimeOtherN
03/28/2017Completed41-60Homeowner (Joint MorFull TimeOtherN
08/21/2016Completed41-60Homeowner (Mortgage)UnemployedOtherN
09/30/2015Default41-60RentingFull TimeOtherN
10/14/2019Active41-60Homeowner (No MortgaFull TimeOtherN
06/26/2019Active41-60Homeowner (Joint MorFull TimeOtherN
12/21/2015Completed41-60Homeowner (Mortgage)Self EmployedOtherN
05/21/2018Active41-60Homeowner (Mortgage)Full TimeOtherN
07/03/2018Active60+RentingFull TimeOtherN
11/02/2017Completed60+Homeowner (Joint MorFull TimeOtherN
01/13/2015Default60+Homeowner (No MortgaFull TimeOtherN
10/10/2019Active18-21Homeowner (Joint MorUnemployedCar LN
02/16/2019Active18-21Homeowner (No MortgaFull TimeCar LN
09/04/2019Active22-30RentingFull TimeCar LN
11/14/2019Active22-30RentingFull TimeCar LN
03/07/2019Active31-40Homeowner (No MortgaUnemployedCar LN
07/27/2019Active31-40Homeowner (Joint MorFull TimeCar LN
09/08/2019Active31-40RentingFull TimeCar LN
11/29/2019Active41-60RentingFull TimeCar LN
02/28/2019Default41-60RentingFull TimeCar LN
01/28/2019Active41-60Homeowner (Joint MorFull TimeCar LN
09/05/2019Active41-60Homeowner (No MortgaFull TimeCar LN
11/08/2017Completed18-21RentingFull TimeCar LoanN
06/04/2018Active18-21RentingFull TimeCar LoanN
09/22/2017Active18-21Homeowner (No MortgaFull TimeCar LoanN
02/25/2016Completed18-21Homeowner (Mortgage)Self EmployedCar LoanN
02/01/2013Completed18-21Homeowner (Joint MorFull TimeCar LoanN
09/13/2017Completed18-21Homeowner (Joint MorFull TimeCar LoanN
12/06/2016Completed22-30Living with ParentsFull TimeCar LoanN
11/07/2016Active22-30Homeowner (No MortgaFull TimeCar LoanN
06/06/2014Completed22-30Homeowner (Joint MorFull TimeCar LoanN
07/25/2018Late22-30Homeowner (Mortgage)Full TimeCar LoanN
06/09/2016Completed22-30Homeowner (Joint MorFull TimeCar LoanN
02/11/2018Completed22-30Homeowner (No MortgaFull TimeCar LoanN
11/25/2013Completed22-30Homeowner (Joint MorFull TimeCar LoanN
06/28/2016Completed22-30RentingPart TimeCar LoanN
03/15/2017Completed22-30Homeowner (Mortgage)Full TimeCar LoanN
04/06/2011Completed31-40Homeowner (Joint MorFull TimeCar LoanN
10/25/2012Completed31-40RentingFull TimeCar LoanN
04/29/2015Completed31-40Homeowner (Joint MorFull TimeCar LoanN
08/02/2018Active31-40Homeowner (Joint MorFull TimeCar LoanN
08/26/2015Completed31-40Living with ParentsFull TimeCar LoanN
04/12/2011Completed31-40Homeowner (Joint MorFull TimeCar LoanN
02/12/2018Late31-40Living with ParentsFull TimeCar LoanN
08/18/2016Completed31-40Homeowner (Joint MorFull TimeCar LoanN
02/27/2016Completed31-40RentingFull TimeCar LoanN
01/09/2020Active31-40Homeowner (Joint MorFull TimeCar LoanN
07/18/2017Active31-40Homeowner (Mortgage)Full TimeCar LoanN
03/21/2016Default31-40Homeowner (No MortgaFull TimeCar LoanN
01/24/2018Active31-40Homeowner (No MortgaFull TimeCar LoanN
10/10/2016Default31-40RentingPart TimeCar LoanN
03/09/2017Default31-40Homeowner (Joint MorPart TimeCar LoanN
03/10/2015Completed31-40Homeowner (Joint MorFull TimeCar LoanN
05/09/2016Completed31-40Homeowner (No MortgaFull TimeCar LoanN
10/23/2014Completed31-40Homeowner (Joint MorFull TimeCar LoanN
05/30/2016Completed31-40Homeowner (No MortgaFull TimeCar LoanN
05/20/2013Completed31-40Homeowner (No MortgaFull TimeCar LoanN
09/13/2017Completed41-60Homeowner (Mortgage)Full TimeCar LoanN
03/30/2017Completed41-60Homeowner (Mortgage)Full TimeCar LoanN
09/22/2017Default41-60Homeowner (Joint MorFull TimeCar LoanN
01/22/2013Completed41-60Living with ParentsPart TimeCar LoanN
11/12/2018Completed41-60RentingFull TimeCar LoanN
04/28/2016Completed41-60Homeowner (Joint MorFull TimeCar LoanN
11/23/2015Completed41-60Homeowner (No MortgaFull TimeCar LoanN
09/03/2018Active41-60Living with ParentsFull TimeCar LoanN
03/28/2014Completed41-60Homeowner (Joint MorPart TimeCar LoanN
11/18/2016Completed41-60RentingFull TimeCar LoanN
07/04/2016Active41-60Homeowner (No MortgaFull TimeCar LoanN
09/22/2017Default41-60Homeowner (Mortgage)Part TimeCar LoanN
10/31/2011Completed41-60Living with ParentsFull TimeCar LoanN
07/18/2018Completed41-60RentingFull TimeCar LoanN
12/11/2018Active60+Homeowner (Joint MorFull TimeCar LoanN
07/17/2017Active60+Homeowner (Joint MorFull TimeCar LoanN
08/09/2016Completed60+RentingFull TimeCar LoanN
03/15/2019Active18-21Homeowner (No MortgaFull TimeDebtN
06/12/2019Completed18-21Living with ParentsFull TimeDebtN
09/06/2019Active18-21RentingSelf EmployedDebtN
05/09/2019Active18-21Homeowner (Joint MorSelf EmployedDebtN
01/04/2019Active22-30Homeowner (Joint MorFull TimeDebtN
07/08/2019Completed31-40Living with ParentsFull TimeDebtN
10/11/2019Active41-60Homeowner (No MortgaFull TimeDebtN
08/05/2019Completed41-60Homeowner (No MortgaFull TimeDebtN
02/05/2019Completed60+Homeowner (Joint MorFull TimeDebtN
03/24/2016Completed18-21Homeowner (Joint MorContractingDebt ConsoliditationN
06/12/2018Completed18-21Homeowner (Mortgage)Full TimeDebt ConsoliditationN
03/22/2011Completed18-21RentingFull TimeDebt ConsoliditationN
07/21/2017Completed22-30Homeowner (Joint MorFull TimeDebt ConsoliditationN
12/04/2018Active22-30Homeowner (Mortgage)Full TimeDebt ConsoliditationN
08/09/2017Completed22-30RentingFull TimeDebt ConsoliditationN
12/15/2015Completed22-30Homeowner (Joint MorPart TimeDebt ConsoliditationN
06/20/2017Active31-40Living with ParentsPart TimeDebt ConsoliditationN
05/24/2017Completed31-40Homeowner (Mortgage)Self EmployedDebt ConsoliditationN
4 REPLIES 4
Shmuel
Garnet | Level 18

 Mainly your code may work without any syntax error, assuming  the xlsx 
 worksheet was imported correctly to a sas dataset.

 

catkat96
Obsidian | Level 7
Yes! It does work without errors, what I'm trying to see if the logic is correct or not 🙂
PaigeMiller
Diamond | Level 26

Using PROC FREQ seems like a reasonable approach.

 

Most of us will not download or open Microsoft Office documents as they are a security threat. So I didn't look at your data, and can't specifically answer your question. To provide us the data in a more usable form, please follow these instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/

--
Paige Miller
catkat96
Obsidian | Level 7
Okay! Tbh I couldn't work that out but I copied the sample and pasted it as a table... I hope it's good enough.
I used proc freq because this task was in that topic's program. 🙂

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 840 views
  • 0 likes
  • 3 in conversation