02-15-2018 03:44 AM
Could you please help to tune-up the program with 'call symputx'. The macrovariables are not initialized and I don't understand the reason:
options mprint mlogic; data denoms; length PARAMN 8 PARAMCD DENOM $200; infile datalines dsd dlm = "@"; input PARAMN PARAMCD DENOM; call symputx(compress(PARAMCD||put(_N_,best.)),PARAMCD); call symputx(compress(DENOM||put(_N_,best.)),DENOM); datalines; 11 @ AUCIFO @ 0 12 @ AUCLST @ 0 13 @ CMAX @ 0 14 @ TMAX @ 2 15 @ LAMZ @ 4 16 @ LAMZHL @ 1 21 @ CLFO @ 2 22 @ VZFO @ 0 31 @ CLO @ 2 32 @ VZO @ 0 33 @ VSSO @ 0 34 @ AUMCLST @ 0 35 @ AUMCIFO @ 0 36 @ MRTIVLST @ 1 41 @ AUCTAU @ 0 42 @ CMIN @ 0 43 @ CTROUGH @ 0 44 @ CAVG @ 0 ; run;
02-15-2018 03:48 AM
02-15-2018 03:48 AM
02-15-2018 04:04 AM
Thats really not a good way to go, remember macro is not a replacement for Base SAS. You have data in one table, you need to use this in another table, then you merge the data from one onto another. This is a very simple and common process that is used in almost every program, do not try to ignore that and write macro code to do the same thing. Thousands of lines of dodgy macro code, or a simple merge statement by paramcd...
02-15-2018 05:11 AM - edited 02-15-2018 05:14 AM
I completely agree that code should not be complicated unless absolutely necessary. But please have a look where the macrovariables are used further:
%macro num_to_char; %do i = 1 %to 18; if PARAMCD in ("&&PARAMCD&i.") then do;
QVAL_Mean_C = put(QVAL_Mean,16.%eval(&&DENOM&i.+1)-L); QVAL_StdDev_C = put(QVAL_StdDev,16.%eval(&&DENOM&i.+2)-L); QVAL_Min_C = put(QVAL_Min,16.&&DENOM&i.-L); QVAL_Median_C = put(QVAL_Median,16.%eval(&&DENOM&i.+1)-L); QVAL_Max_C = put(QVAL_Max,16.&&DENOM&i.-L);
end; %end; %mend num_to_char; data tableX ; format QVAL_Mean_C QVAL_StdDev_C QVAL_Min_C QVAL_Median_C QVAL_Max_C $200.; set proc_mean_results; NObs_C = put(NObs,16.0-L); %macro num_to_char; run;
The list of parameters or the number of decimals can be changed anytime. I hope that using of the approach outlined can help to react faster.
02-15-2018 05:30 AM
Exactly the code I would avoid like the plague, lists of data, loops all kinds of things, all of which will go wrong at some point. An example of using merge:
data want (drop=denom); merge lab_data param_data; by paramcd; qval_stddev_c=putn(qval_stddev,16,denom); ... run;
So much simpler and expandable as any dataset is. Also note that by the use of paramcd I assume your using either LAB model, LB domain, or an ADaM BDS structure. For LAB, LB precision should already be a variable, and for ADaM, this should be present in some form or other, perhaps already rounded?
Need further help from the community? Please ask a new question.