Hello, I have a listing of patients and their dates of admits and releases by facility type. For example, patient 1 has four lines. He was in facility A from 09OCT23 - 22DEC23 then facility B continuously from 23JUL24 - . (current). I would like in my final table to have only 2 lines for patient 1: admit=09OCT23 - release=22DEC23 and admit=30AUG24 - release=. I only care about the admits for facility A, BUT if he was in facility A and was transferred to facility B in a continous time series, I want the last release date in the series, regadless of the facility. In this scenario, he started on 23JUL24 in facility B and ended in facility A but I only want the facility A date range admit=30AUG24 and release=. Please help, I tried with retain, with LAG... but without success... Thank you. my initial table: id facility amit release 1 A 09OCT23 22DEC23 1 B 23JUL24 27AUG24 1 B 27AUG24 30AUG24 1 A 30AUG24 . 2 A 15DEC23 14JAN24 2 B 14JAN24 22JAN24 2 A 22JAN24 08MAR24 and my final table would be: id facility admit release 1 A 09OCT23 22DEC23 1 A 30AUG24 . 2 A 15DEC23 08MAR24 Here's what I tried: proc sort data=DELETE; by id admit;
data TEST (drop=_:);
do until ((release+1 < _next_admit) or last.juvnum=1);
set DELETE;
by id admit;
merge DELETE DELETE (firstobs=2 keep=admit rename=(admit=_next_admit));
_min_admit=min(_min_admit,admit);
if release=. and last.admit=0 then release=_next_admit-1;
end;
admit=_min_admit;
run; But, with this code, I get this. The first record is okay, but the second line starts with the admit of facility B and I only want facility A admits and then the release date is that of the next id admit. id facility admit release 1 A 09OCT23 22DEC23 1 A 23JUL24 15DEC23 2 A 15DEC23 08MAR24 Thank you in advance!
... View more
Hello, experts!
Has anyone encountered the need to use one library for different users? Could you please advise if this can be realised using the regular Managemnet Console apparatus (not using autoexec custom, but using User manager)?
For example, there is a TEST library and two users: TEST_USER1 and TEST_USER2. Each user has a different set of permissions on objects at the database level. We want to have one library in the Management console, but depending on the current user (groups he/she is a member of) when using it on Stored Process Server, Pooled Workspace Server and Workspace server, the connection string to the library includes either credentials of TEST_USER1 or TEST_USER2.
... View more
Dear all, I have used the following R function in order to estimate the upper bound PD given the number of obligors and defaults, considering the Pluto & Tasche approach. I'd be so grateful if you tell me how can I achieve the same results, however, just using PROC IML and SAS native functions, instead of having the R running in the background? Thanks in advance. Rgs, Raphael proc iml; submit / R; # Estimates the Upper Pound PD given the number of obligors and defaults plutotashe <- function(n, i, theta, rho, T, Conf, N) { hh = uniroot(error, interval=c(0,1), lower=0.000000001, upper=0.999999999, tol = 1e-8, maxiter=500, n=n, i=i, theta=theta, rho=rho, T=T, Conf=Conf, N=N) names(hh) = c("UpperBoundPD", "Function", "iter", "estim.prec") return(hh) } # Error Function error <- function(pd, n, i, theta, rho, T, Conf, N) { AverageSim = 1-mean(replicate(N, sim(pd,n,i,theta,rho, T))) error = AverageSim-Conf return(error) } # Simulation Run sim = function(pd, n, i, theta, rho, T) { # Generate a state of the economy Z=array(0,c(T,1)) Z[1] = rnorm(1) if (T > 1) { for (j in 2:T) { Z[j] = theta*Z[j-1]+sqrt(1-theta^2)*rnorm(1) } rm(j) } p = 1-prod(1 - pnorm((qnorm(pd)-Z*sqrt(rho))/sqrt(1-rho))) # Prob of Defaulting (tt=binom_cum(n,p,i)) return(tt) } # Cumulative Binomial binom_cum = function (n,p,i) { bc = 0 for (j in 0:i) { bc = bc + choose(n,j)*(p^j)*((1-p)^(n-j)) } return(bc) } n <- 800 #number of obligors i <- 0 #number of defaults theta <- 0.30 #year-to-year correlation rho <- 0.12 #asset correlation T <- 5 #number of years Conf <- 0.99 #confidence level N <- 1000 #number of simulations plutotashe(n, i, theta,rho,T,Conf, N) endsubmit; quit;
... View more
I have a long file with data like this:
Some projids have one or more of the 13 rows missing, but it's random as to which row(s) are missing. What is the easiest way to write code to add the rows that are missing for each projid?
Thanks!!
... View more