Recent content by sandeep249

  1. S

    reshaping data

    I am trying to reshape data in SAS in a very specific way. The data looks like: ID Q1 Q2 491 0 0 491 0 1 1040 0 1 1040 1 0 1040 2 1 And, I want to transform the data to the following shape: ID Q1A Q1B Q2A Q2B 491 0 0 0 1 1040 0 1 1 0 1040 0 2 1 1 1040 1 2 0 1 So, a pair of variables...
  2. S

    How to calculate Log Hazard Ratio in SAS

    proc phreg data = analysis ; class c diabetes /descending; model days*ind(0) = c diabetes id/ rl ; id= c *diabetes; hazardratio id; run; I am trying to run a simple Cox Regression in SAS. I cant seem to find a way to calculate log-hazard ratio for my variables in the model. The hazard...
  3. S

    Finding Optimal Cutpoints for Continuous Covariates with Time-to-Event Outcomes

    I found this interesting article from MayoClinic, where they talked about a macro that finds a cut point for a continuous variable with a time to event outcome. Does anyone know where I can find this macro? Is there a macro repository that might have this macro? It is not available on the...
  4. S

    Stack columns (in same dataset) in SAS

    I know that you can concatenate Using the DATA Step for different data sets. But how do you stack specific columns in the same data set? I have variables x1 to x10 in a data set. And I want to stack them into two columns: (col 1): x1, x3, x5, x7, and x9 and (Col 2): x2, x4, x6, x8, and x10...
  5. S

    PROC IML module for CDF

    How would one create a proc iml module to calculate the cdf? Denote f(x;μ,σ) and F(x;μ,σ), respectively, the p.d.f. and the c.d.f. of N(μ,σ^2). The p.d.f. and the c.d.f. of contaminated normal cN(μ,σ2,σc^2,p) (a N(μ,σ^2) contaminated in spread by a N(μ,σc^2) with probability p) are...
  6. S

    PROC SQL macro into an ARRAY

    I am trying to create a macro (&varlist) using proc sql ---> then putting the variable into the array item[3]. But I get the error "Too few variables defined for the dimension(s) specified for the array item" What's wrong here? Any help would be greatly appreciated. proc sql noprint...
  7. S

    SAS: cdf for contaminated normal (PROC IML)

    Denote f(x;μ,σ) and F(x;μ,σ), respectively, the p.d.f. and the c.d.f. of N(μ,σ^2). The p.d.f. and the c.d.f. of contaminated normal cN(μ,σ2,σc^2,p) (a N(μ,σ^2) contaminated in spread by a N(μ,σc^2) with probability p) are (1-p)f(x;μ,σ)+pf(x;μ,σc) and (1-p)F(x;μ,σ)+pF(x;μ,σc), respectively...
  8. S

    Re-arranging SAS data

    I have data in this format: Admit Gender Department Count Admitted Male A 512 Rejected Male A 313 Admitted Female A 89 Rejected Female A 19 Admitted Male B 353 Rejected Male B 207 Admitted Female B 17 Rejected Female B 8...
  9. S

    MLE of P(X<2) - Exponential distribution

    The problem statement: Find the MLE of θ = P (X≤ 2) in a random sample of size n selected from an exponential distribution EXP(λ) Relevant equations f(x, λ) = λ e^(-λx) F(x, λ) = 1 - e^(-λx) The attempt at a solution I know how to find the MLE of the mean of an exponential...
  10. S

    Generating Random Sample

    I know that R can easily generate random samples for know distributions - normal, exponential, uniform. But how can I generate a random sample from a known probability distribution (that is not listed)? The probability distribution is rather simple: f(x) = 2x^-3 So, how can I generate a...
  11. S

    Generating Random Sample

    I know that SAS can easily generate random samples for know distributions - normal, exponential, uniform. But how can I generate a random sample from a known probability distribution (that is not listed)? The probability distribution is rather simple: f(x) = 2x^-3 So, how can I generate a...