Kaz's SAS, HLM, and Rasch Model My SAS questions and SAS's responses

PROC MIANALYZE on PROC MEANS result
Thanks Rob. [SAS 7610176377] proc mianalyze

data missing;
do rep=1 to 100;
if ranuni(12143)>.4 then x=rannor(2111)*100+44; if ranuni(13330)>.9 then y=rannor(2211)*10; if ranuni(12213)>.5 then z=rannor(2114)+70; output; end;
ods trace on;
proc mi data=missing out=impute nimpute=3 seed=1000; ods select parameterestimates; var x y z; run;
proc means data=impute mean stderr noprint; var x y z; by _imputation_; output out=mean_ds mean=mean_x mean_y mean_z stderr=stderr_x stderr_y stderr_z; run;
proc mianalyze data=mean_ds;
ods select parameterestimates;
modeleffects mean_x mean_y mean_z;
stderr stderr_x stderr_y stderr_z;
run;

Length
Thanks, Jan. Based on [SAS 7610138678] question about the length of a numeric variable
data test;
input numval :;
format numval best20.;
datalines;
2.2
1
5.43243
10003.300204
;
data result;
set test;
digit_count = length(strip(put(numval,best20.)));
run;
proc print; run;

Adding leading zeros (e.g., 123 --> 0123)

(Thanks, Kim.  Based on [SAS 7610121586] A question about a character function)

In order to create variable NEW_ID, you can use the PUT function and the format Zw. which adds leading zeros to the specified length. Here's an example:

new_id=put(id,z4.);

Sample 26140: Creating a new data set for each BY-Group in a data set
Thanks, Russ.  [SAS 7610122275] break a data into separate pieces by a group ID
Getting/saving residuals in a SAS data set from PROG GLIMMIX
Thanks, Phil.  [SAS 7610132116] how to get residuals from PROC GLIMMIX]

output out=stats residual=resid;

 Copyright 2005 KU For information inquiry (AT) estat.us