BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

First, set these options in the first line of your program and run it again.

options mprint symbolgen mlogic;

Show us the entire log for this step, with nothing chopped out. We need to see the code, NOTEs, WARNINGs and ERRORs. The next part is absolutely crucial, do not skip this next part. Click on the </> icon and paste the log into the window that appear. This will help us interpret the log by maintaining the formatting and spacing, please help us out and help yourself as well by doing this. Do not skip this part.

--
Paige Miller
JovanaUniCredit
Calcite | Level 5

Should I run whole program or just that line that you wrote me?

PaigeMiller
Diamond | Level 26

@JovanaUniCredit wrote:

Should I run whole program or just that line that you wrote me?


You run the entire program again, with those options in the first line of the code.

--
Paige Miller
JovanaUniCredit
Calcite | Level 5

This is the output of the log:

 

1 The SAS System Tuesday, April 28, 2020 12:45:00 PM

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program';
4 %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5 %LET _CLIENTPROJECTPATH='\\srvnas\common\CRO\Strategic Risk\Credit risk Governance and Models\Credit Risk Modeling\IFRS
5 ! 9\03 IFRS 9 Modeling\02 IFRS 9 TL modeling\QE & TL 2020\Transfer logic\IFRS 9 2020 TL v8.egp';
6 %LET _CLIENTPROJECTPATHHOST='UCB29756';
7 %LET _CLIENTPROJECTNAME='IFRS 9 2020 TL v8.egp';
8 %LET _SASPROGRAMFILE='';
9 %LET _SASPROGRAMFILEHOST='';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
SYMBOLGEN: Macro variable SASWORKLOCATION resolves to "F:\WORK\_TD4820_SRVSAS06_\Prc2/"
21 ENCODING=UTF8
22 options(rolap="on")
23 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24
25 GOPTIONS ACCESSIBLE;
26 options mprint symbolgen mlogic;
27 options compress=binary;
28
29
30
31 DATA QntRegTest;
32 SET QntRegCorp /*QntRegCorpNonRev*/ /*QntRegCorpREV*/;
33
34 /*ISTA JE PODELA KOD SVA 3 segmenta*/
35 IF RatingClassFirstAv in (1,2,3,4,5) THEN I1 = 1;
36 ELSE I1 = 0;
37 IF RatingClassFirstAv in (6,7,8) THEN I2 = 1;
38 ELSE I2 = 0;
39
40 LnAge1 = LnAge*I1;
41 LnAge2 = LnAge*I2;
42
43 RUN;

NOTE: There were 26168 observations read from the data set WORK.QNTREGCORP.
NOTE: The data set WORK.QNTREGTEST has 26168 observations and 79 variables.
NOTE: Compressing data set WORK.QNTREGTEST decreased size by 83.41 percent.
Compressed is 106 pages; un-compressed would require 639 pages.
NOTE: DATA statement used (Total process time):
real time 0.32 seconds
cpu time 0.32 seconds

44
45 PROC QUANTREG DATA=QntRegTest OUTest=QntRegEst algorithm=interior (tolerance=1e-5) ci=resampling;
2 The SAS System Tuesday, April 28, 2020 12:45:00 PM

46 MODELLnAge12WORM: MODEL AP1 = LnPD0 LnAge1 LnAge2 / quantile=0.9 /*plots=all*/;
47 /*testAll: test LnPD0 LnAge1 LnAge2/ wald lr*/;
48 OUTPUT OUT=QntRegLnAge12 p=predicted;
49 title 'Quantile regression';
50 RUN;

NOTE: The data set WORK.QNTREGEST has 1 observations and 10 variables.
NOTE: Compressing data set WORK.QNTREGEST increased size by 100.00 percent.
Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: The data set WORK.QNTREGLNAGE12 has 26168 observations and 81 variables.
NOTE: Compressing data set WORK.QNTREGLNAGE12 decreased size by 82.79 percent.
Compressed is 110 pages; un-compressed would require 639 pages.
NOTE: PROCEDURE QUANTREG used (Total process time):
real time 1.12 seconds
cpu time 1.15 seconds

51
52 DATA check;
53 SET QntRegLnAge12;
54 IF AP1 > predicted then Stage = 2; else Stage = 1;
55 dummy = 1;
56 RUN;

NOTE: There were 26168 observations read from the data set WORK.QNTREGLNAGE12.
NOTE: The data set WORK.CHECK has 26168 observations and 83 variables.
NOTE: Compressing data set WORK.CHECK decreased size by 83.05 percent.
Compressed is 111 pages; un-compressed would require 655 pages.
NOTE: DATA statement used (Total process time):
real time 0.23 seconds
cpu time 0.23 seconds

57
58 DATA QRParameters;
59 SET check;
60
61 Intercept = -0.6436; /*PROMENA*/
62 Coeff_LnPD0 = -0.2536; /*PROMENA*/
63 Coeff_LnAge1 = 0.6548; /*PROMENA*/
64 Coeff_LnAge2 = 0.2851; /*PROMENA*/
65 ALPHA =
65 ! SQRT((exp(Intercept+Coeff_LnPD0*log(0.005985769))*0.005985769)*(exp(Intercept+Coeff_LnPD0*log(0.023412558))*0.023412558))
65 ! ;
66 RUN;

NOTE: There were 26168 observations read from the data set WORK.CHECK.
NOTE: The data set WORK.QRPARAMETERS has 26168 observations and 88 variables.
NOTE: Compressing data set WORK.QRPARAMETERS decreased size by 81.53 percent.
Compressed is 121 pages; un-compressed would require 655 pages.
NOTE: DATA statement used (Total process time):
real time 0.29 seconds
cpu time 0.29 seconds

67
68 DATA beta_min_max;
69 SET QRParameters;
3 The SAS System Tuesday, April 28, 2020 12:45:00 PM

70
71 IF (Coeff_LnAge1 > 0 AND Coeff_LnAge2 > 0) THEN DO;
72 MIN = 0;
73 MAX = (1- ALPHA)/LOG(50);
74 END;
75 ELSE IF (Coeff_LnAge1 < 0 AND Coeff_LnAge2 < 0) THEN MAX = 0 AND MIN = -1*(ALPHA)/LOG(50);
76 RUN;

NOTE: There were 26168 observations read from the data set WORK.QRPARAMETERS.
NOTE: The data set WORK.BETA_MIN_MAX has 26168 observations and 90 variables.
NOTE: Compressing data set WORK.BETA_MIN_MAX decreased size by 81.38 percent.
Compressed is 119 pages; un-compressed would require 639 pages.
NOTE: DATA statement used (Total process time):
real time 0.29 seconds
cpu time 0.29 seconds

77
78 DATA realized_thresholds/*realized_thresholds_RCG1 realized_thresholds_RCG2*/;
79 SET beta_min_max (KEEP= LnPD0 PDPuncFirstAv RatingClassFirstAV RatingFirstAV RatingCurr RefDate Age ClientID ClientName
79 ! TransID SegmentFinal I1 I2 predicted PDPuncFirstAv PDPuncCurr Intercept Coeff_LnPD0 Coeff_LnAge1 Coeff_LnAge2 ALPHA MIN
79 ! MAX LnAge1 LnAge2);
80
81 PDThreshold = EXP(predicted)*PDPuncFirstAv; /* Predicted PD at reporting date (i.e. PD threshold)*/
82 IF PDThreshold >= 0.99 THEN PDThreshold = 0.99;
83 /*PDPuncCurr- OBSERVED PD at reporting date*/
84 IF (PDPuncCurr > PDThreshold) THEN StgChange = 1; /* boolean vector which indicates stage 2 obs. - 1's are in stage 2,
84 ! 0's in stage 1 */
85 ELSE StgChange = 0;
86
87 *IF I1 = 1 THEN OUTPUT realized_thresholds_RCG1;
88 *ELSE OUTPUT realized_thresholds_RCG2;
89 RUN;

NOTE: There were 26168 observations read from the data set WORK.BETA_MIN_MAX.
NOTE: The data set WORK.REALIZED_THRESHOLDS has 26168 observations and 26 variables.
NOTE: Compressing data set WORK.REALIZED_THRESHOLDS decreased size by 89.51 percent.
Compressed is 67 pages; un-compressed would require 639 pages.
NOTE: DATA statement used (Total process time):
real time 0.18 seconds
cpu time 0.18 seconds

90
91
92 PROC SQL;
93 CREATE TABLE obs_stg_change AS
94 SELECT t1.*, sum(t1.StgChange) as sum_StgChange,
95 count(t1.TransID) as no_obs,
96 (SUM(t1.StgChange))/count(t1.TransID) as QUANTILE,
97 (1-(SUM(t1.StgChange))/count(t1.TransID)) AS quantile_or
98
99 FROM realized_thresholds /*realized_thresholds_RCG1 realized_thresholds_RCG2*/ t1;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Compressing data set WORK.OBS_STG_CHANGE decreased size by 88.55 percent.
Compressed is 75 pages; un-compressed would require 655 pages.
NOTE: Table WORK.OBS_STG_CHANGE created, with 26168 rows and 30 columns.

4 The SAS System Tuesday, April 28, 2020 12:45:00 PM

100
101 QUIT;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.21 seconds
cpu time 0.21 seconds

102
103
104 %macro makro(korak,broj);
105 DATA CTAge;
106 SET obs_stg_change;
107 step=((1-alpha)/log(50))/(50-1);
108 y= alpha+ &korak*log(Age);
109 IF(I1=1) THEN min_Threshold = min(y,PDThreshold);
110 IF(I2=1) THEN max_Threshold = max(y,PDThreshold);
111 min_max_Threshold=COALESCE(min_Threshold, max_Threshold);
112 IF PDPuncCurr > min_max_Threshold THEN StgChange_CT = 1; ELSE StgChange_CT = 0;
113 RUN;
114
115 /*0.5757232999 SUM SQUARE*/
116
117 PROC SQL;
118 CREATE TABLE CTAge_obs&broj AS
119 SELECT &korak AS step, min(t1.sum_StgChange) as sum_StgChange,
120 (SUM(t1.StgChange_CT)) AS SUM_StgChange_CT, /*a1*//* count # of obs which change stage */
121 /* (SUM(t1.StgChange_CT) - t1.sum_StgChange) AS PROVERA,*/
122 /* (SUM(abs(t1.StgChange_CT-t1.StgChange))) AS SUM_StgChange_DIFF,*/ /*Calculate distance between old CT and
122 ! new one */
123 (SUM((t1.min_max_Threshold-t1.PDThreshold)**2)) AS SSQ2, /*sum of square*/
124 SQRT(SUM((t1.min_max_Threshold-t1.PDThreshold)**2)) AS dist_prov, /* square root of the distance */
125 ABS(SUM(t1.StgChange_CT) - min(t1.sum_StgChange)) AS err_stage2, /* Sum of obs which change stage */
126 ABS(SUM(t1.StgChange_CT)-sum(t1.StgChange))/MIN(t1.no_obs) AS ee
127 FROM WORK.CTAge t1;
128 QUIT;
129 %mend;
130
131 %macro sqlloop(start,end,step,pocetak,kraj);
132 PROC SQL;
133 %DO i=&start. %TO &end. %BY &step.;
134 %DO j=&pocetak. %TO &kraj.;
135 %makro(i,j);
136 %END;
137 %END;
138 QUIT;
139 %mend;
140
141 GOPTIONS NOACCESSIBLE;
142 %LET _CLIENTTASKLABEL=;
143 %LET _CLIENTPROCESSFLOWNAME=;
144 %LET _CLIENTPROJECTPATH=;
145 %LET _CLIENTPROJECTPATHHOST=;
146 %LET _CLIENTPROJECTNAME=;
147 %LET _SASPROGRAMFILE=;
148 %LET _SASPROGRAMFILEHOST=;
149
150 ;*';*";*/;quit;run;
151 ODS _ALL_ CLOSE;
5 The SAS System Tuesday, April 28, 2020 12:45:00 PM

152
153
154 QUIT; RUN;
155

 

 

It is strange that now there is no error, but no tabels in output of the macro exists.

PaigeMiller
Diamond | Level 26

I asked you to not skip the step of pasting the log into the window that appears when you click on the </> icon, and you skipped this step. Please provide the log by following the instructions given. This help us interpret the log properly, and thus you get faster/better answers.

--
Paige Miller
Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

From %DO, Iterative Macro Statements:

Required Arguments

macro-variable

names a macro variable or a text expression that generates a macro variable name. Its value functions as an index that determines the number of times the %DO loop iterates. If the macro variable specified as the index does not exist, the macro processor creates it in the local symbol table.

You can change the value of the index variable during processing. For example, using conditional processing to set the value of the index variable beyond the stop value when a certain condition is met ends processing of the loop.

startstop

specify integers or macro expressions that generate integers to control the number of times the portion of the macro between the iterative %DO and %END statements is processed.

The first time the %DO group iterates, macro-variable is equal to start. As processing continues, the value of macro-variable changes by the value of increment until the value of macro-variable is outside the range of integers included by start and stop.

increment

specifies an integer (other than 0) or a macro expression that generates an integer to be added to the value of the index variable in each iteration of the loop. By default, increment is 1. Increment is evaluated before the first iteration of the loop. Therefore, you cannot change it as the loop iterates.

 
 
(Emphasis by me)
The macro preprocessor, as a pure code generator, has no use for non-integers, as you don't repeat a statement 0.1 or 2.5 times.
 
Which code do you want to create with your macro construction?
JovanaUniCredit
Calcite | Level 5

Does it mean that my macro cannot work with decimal numbers?

 

SInce arguments for my macro are decimal numbers.

Kurt_Bremser
Super User

@JovanaUniCredit wrote:

Does it mean that my macro cannot work with decimal numbers?.


That's obvious from the doc, isn't it?

 

I repeat my question: which code do you want to create with your macro construction? If you really need decimals as parameters for another macro, you can create them in a data step, and use CALL EXECUTE() to execute the code that needs those decimals.

But before we talk about methods, we need to know the final goal.

ballardw
Super User

Last time I checked the %by only works for non-zero integer values.

Since you have your macro variable step with values like 0.001 then SAS does not know how to evaluate the incrementation of the %i value.

 

increment

specifies an integer (other than 0) or a macro expression that generates an integer to be added to the value of the index variable in each iteration of the loop. By default, increment is 1. Increment is

evaluated before the first iteration of the loop. Therefore, you cannot change it as the loop iterates.

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
  • 38 replies
  • 2099 views
  • 1 like
  • 6 in conversation