Hi every one,
I want to create a change from baseline table from a sample data attached below
I have already create a CHANGE variable that is the difference of after (ANRIND) and baseline (BNRIND).
My code is that:
proc report data=Test nowd completerows completecols split="$"
style(report)=[outputwidth=100%];
Label PARAM="Laboratory Parameter";
by PARAM;
column PARAM AVISIT ("Timepoint" TRTA) ("Actual Value~R/RTF'\brdrb\brdrs\li100\ni100'" BNRIND) ("Change From Baseline~R/RTF'\brdrb\brdrs\li100\ni100'"Change);
define PARAM--AVISIT /group noprint;
define Change/across " ";
define TRTA / group mlf order=data
style=[width=7.8% pretext=" " asis=on] " ";
define BNRIND/ANALYSIS sum n mean std median min max across " ";
compute before AVISIT;
line @1 " ";
line @1 AVISIT $;
endcomp;
run;
But the result I got is not what I want:
I want to display n, mean, sd,... of BNRIND and CHANGE with each treatment group in each time point so I try to add these options in define
statement but I only got something about actual value
How can I display these statistics ?
Thanks in advance
Hint: showing results that you do not want isn't greatly helpful. Showing results that you do actually want, if we have the data in the form of a data step, is much more likely to get a working solution.
Hi:
A few other comments to add onto the previous requests for actual data and your entire program. I see that you are using the MLF option. Typically, this is used with PRELOADFMT and a custom user-defined format. I do not see any formats being used in your code, so if your data does have a user-defined format assigned permanently, we need to see/know about that format. Also, it's not clear why you are using RTF control strings in your spanning headers, but showing what appears to be ODS HTML output. When you post code, we need to see ALL your statements, including your options, formats and ODS statements, so any program can be run using the SAME options.
Then, are you sure that your program is actually generating the results you posted? I find this very confusing and PROC REPORT will, in the end, use ACROSS and not ANALYSIS for your BNRIND variable.
If you have ANALYSIS as a usage, you should only specify 1 statistic in a DEFINE statement. If you have more than 1 statistic the last statistic is used. If you have what you show (with both ANALYSIS and ACROSS, since ACROSS is listed last, that is what will be used.
Based on the fact that the program has these issues, it really is best to show some sample data in the form of a DATA step that others can run.
Cynthia
So I just found out the code of report step below works fine for me with the test data
proc report data=Test nowd completerows completecols split="$"
style(report)=[outputwidth=100%];
Label PARAM="Laboratory Parameter";
by PARAM;
column PARAM AVISIT ("Timepoint" TRTA) BNRIND,(N Mean STD Median Min Max) Change,(N Mean STD Median Min Max);
define PARAM--AVISIT /group noprint;
define TRTA/group order=data
style=[width=7.8% pretext=" " asis=on] " ";
define Change/Analysis "Change from baseline";
Define BNRIND/Analysis "Actual Value";
compute before AVISIT;
line @1 " ";
line @1 AVISIT $;
endcomp;
run;
But when I use my real data, I need to do some data step (merge) to create the form of test data. And then, the step could not print out the Max statistic with Change variable
My data step is like that:
data work.database1;
set work.database (rename= (Result = BNRIND));
where VISITNUM =1;
drop VISITNUM;
run;
data work.database2;
set work.database (rename= (Result = ANRIND));
drop Sex;
run;
DATA ork.database3;
merge work.database1 work.database2;
by UNISUBID PARAM;
length VISIT $20;
IF VISITNUM=1 then VISIT="Baseline";
IF VISITNUM=2 then VISIT="Week 4";
IF VISITNUM=3 then VISIT="Week 8";
RUN;
The result I want to get is like that
But I only get like that
Could I have nay idea to fix this situation ?
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.