SAS Count function

data one;
input val \$9.;
cards;
102102111
108881111
;

data new;
set one;
temp=count(val,'1');
put temp=;
run;

RT

Creating confidence intervals using datastep

X is a proportion (ranges from 0 to 1).  When alpha is set to 1.96, it creates 95% confidence intervals (two-tail tests).

N is the number of cases.

%let Alpha=1.96;

X_STDERR =sqrt(((X*(1-X))/N));
X_CI95_lower =X-(X_STDERR*&alpha);
X_CI95_upper =X+(X_STDERR*&alpha);

REFERENCE

http://davidmlane.com/hyperstat/B9168.html

Date format

format  DataCollectionDate MMDDYY10.;

HLM equation and PROC MIXED/GLIMMIX syntax

level1 : y= b0 + b1*X + error1
level2: b0=g00 + g01*group+error2
level2: b1=g10 + g11*group + error3

I insert level2 equations into level 1.

level1 : y= g00 + g01*group+error 1+ (g10 + g11*group + error2)*X + error3

level1 : y= g00 + g01*group+error 1+ g10*X + g11*group *X + error2*X + error3

This translates into PROC MIXED syntax in this way.  Independent variables that are right next to the error (error2*X) goes into the random statement.

proc mixed ;
class sub group ;
model y=x group x*group;
random intercept x;
run;

Saving log and output files into external text files (to avoid stopping of a SAS run)

filename printout 'C:\temp\log.txt';
filename logout 'C:\temp\output.txt';
proc printto print=printout log=logout new;
run;

proc printto ;
run;

RETAIN statement to collapse rows

data sample;
input id \$ var1 var2 var3;
datalines;
A 20 . .
A . 30 40
B 20 . .
B 20 . .
C . 10 .
C 10 . .
C . . 10
;

data sample;
set sample;
by id;
array v(3) var1-var3;
array n(3) v1-v3;
retain v1-v3;
do i = 1 to 3;
if v(i) ne . then n(i)=v(i);
end;
if last.id then do;
output;
do j = 1 to 3;
n(j)=.;
end;
end;
drop i j var1-var3;
rename v1=var1 v2=var2 v3=var3;

proc print;
run;

Thanks GP.

Logistic regression and and comparison of group means in the model (using PROC GLIMMIX)

For logistic regression models in PROC GLIMMIX, you need to use dist=binary link=logit option on the MODEL statement (sorry I missed pointing this out in your program in my previous response). So please add these two options.

For logistic regression models, the estimations are all on the logit scale, so is the LSMEANS statement. To get the lsmeans on the original scale (the probability scale), you can use the ILINK option --

lsmeans &group / ilink ;

For difference in the groups, you use the DIFF option on the LSMEANS statement. The results are also on the logit scale. If you use the OR option, you will get the odds ratios for the group effect --

lsmeans &group /diff  or;

Unfortunately, the difference in the probability scale between the groups are not directly available in PROC GLIMMIX. The magnitude of the difference is easy to compute -- you use the results from the ILINK option output, which gives you the estimated probabilities in each group, and compute the difference by hand or by using a data step, however, the appropriate standard errors for these differences are not available in PROC GLIMMIX.

Thanks, JT.

Replace all letters and numeric values into xxxx

This replaces all letters into xxxx.

data a;
q=" Licensed to ICF CONSULTING GROUP, Site 70007867. ";
prx=prxparse("s/[A-Z]/x/io");
call prxchange(prx,-1,q);
drop prx;
run;

proc print;run;

This replaces all letters and numeric values into xxx.

data a;
q=" Licensed to ICF CONSULTING GROUP, Site 70007867. ";
prx=prxparse("s/[A-Z,0-9]/x/io");
call prxchange(prx,-1,q);
drop prx;
run;

proc print;run;

Thanks, KR.