Monte Carlo and quasi-Monte Carlo simulations for credit risk In SAS, we can do quasi-Monte Carlo simulation by Halton’s low-discrepancy sequences, which are better than random variables from uniform distribution . The only procedure in SAS 9.2 to produce Halton’s sequence is probably the MDC procedure in SAS/ETS [Ref. 2] but hard to output. However, we can build a user-defined function by PROC FCMP to realize our goals. I showed an example by modifying the codes from Paolo Brandimarte’s Matlab book [Ref. 1] to estimate the area of an arbitrary surface. Overall, Halton’s method would converge with more sampling points, while uniform randomization will cause estimates fluctuating along the ...
A macro design pattern by PROC FCMP We all heard horrible stories that someone tried to piece together a bunch of nice functioning macros for a big macro, and ended up with a messy and undebuggable system. Part of reasons can be about encapsulation: not all SAS programmers have the good habit to localize the macro variables by %local statement; the leaking macro variables may ruin the attempt to utilize multiple macros written by different SAS programmers. To solve this problem, Mark Tabladillo brought the concepts of encapsulation, polymorphism, and inheritance into nested macros. And he raised several design patterns for macros to emulate the object-oriented languages.The ...
Top 10 reasons for a modeler to learn PROC FCMP 10.  New financial functions34 pre-compiled financial functions were shipped with SAS for free, which can be called in DATA step.9. A management GUIThere is a nice-looking Java-powered GUI to manage the user-defined functions: SAS FCmp function editor.8. Dynamic parametersParameters from other statistical procedures in SAS can be passed to a function. We can use a macro to wrap PROC FCMP to create tons of data-driven functions (temporary or permanent).7. Migration from VBAExcel dominates every desktop. However, using VBA to process large data is just a pain, such as calculating a transition matrix for probability of default. PROC FCMP is built ...
Why sometimes use DATA Step instead of PROC SQL A questionThere is an interesting thread about the efficiency of PROC SQL on Mitbbs.com.Both datasets have1 and have2 have few variables, but many observations. Very simple program, but without any result after running it for a whole afternoon.proc sql; create table want as select * from have1 as a left have2 as b on b.serie_beg <= a.serie <= b.serie_end;quit;If I replace left join with inner join, the result is the same. Why it takes so long?Four types of joins in PROC SQLTo understand this question, we may have to go back into PROC SQL. A technical paper introduces that like ...
The complexity for Fibonacci numbers in SAS Fibonacci numbers have a lot of applications. There have been a lot of interesting researches regarding Fibonacci numbers since 800 years ago. Mathematically they are the numbers from a sequence, which is defined as . Experiment and ResultFibonacci numbers can be derived from either the original definition that is a typical example of recursion, or a mathematically simplified form that is called closed-from expression. In SAS, a user-defined Fib1 function in PROC FCMP can realize the recursion expression, and another Fib2 function is created to express the closed-form expression. I insert both functions to a loop from 10 to 40 ...