BookmarkSubscribeRSS Feed
James_Yu
Obsidian | Level 7

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: 

James_Yu_0-1629952302091.png

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

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20
I can't see what you want as I won't download an MS Office file, but the description seems like a good fit for proc tabulate. Why not use it?
ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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.

Cynthia_sas_0-1630006170406.png

 

  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

James_Yu
Obsidian | Level 7

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

James_Yu_0-1630041114105.png

But I only get like that

James_Yu_1-1630041221488.png

Could I have nay idea to fix this situation ?

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1914 views
  • 0 likes
  • 4 in conversation