Help using Base SAS procedures

PROC REPORT(sorry if not posted properly)

Reply
Occasional Contributor
Posts: 5

PROC REPORT(sorry if not posted properly)

[ Edited ]

Hello,

I have the data and need to do this exact table

 

Table 1.0

(Demo Graphics & Base Line Characteristics)

 

 

Active (N= XX)

Placebo (N= XX)

Overall (N= XX)

Age (years)

 

 

 

N

XX

XX

XX

Mean

XX.X

XX.X

XX.X

Standard Deviation

     XX.XX

XX.XX

XX.XX

Minimum

XX.X

XX.X

XX.X

Maximum

XX.X

XX.X

XX.X

Gender

 

 

 

Male

XX(XX.X%)

XX(XX.X%)

XX(XX.X%)

Female

XX(XX.X%)

XX(XX.X%)

XX(XX.X%)

Race

 

 

 

White

XX(XX.X%)

XX(XX.X%)

XX(XX.X%)

Black

XX(XX.X%)

XX(XX.X%)

XX(XX.X%)

Other*

XX(XX.X%)

XX(XX.X%)

XX(XX.X%)

 

 

* Other includes Asian, Native American, and other races.

*To create frequencies, percentages use proc freq

* To create n, mean, median, min, max, standard deviation use proc univariate.

 

 

 

 

I'm not sure if this is the correct way of doing it but I keep getting errors. I am so lost at this. all help is appreciated. Thank you in advance.

 

 

data DEMOG;
	set TMP1.DEMOG;

	if trt=0 then
		do;
			output;
			trt=2;
			output;
		end;

	if trt=1 then
		do;
			output;
			trt=2;
			output;
		end;
run;

/*stats for age group*/
proc univariate data=demog noprint;
	CLASS TRT;
	var age;
	Output out=AGEDS n=_n mean=_mean std=_std min=_min max=_max;
run;

proc sort ;
	by trt;
run;

proc transpose data=AGEDS out=tranage;
	by trt;
	VAR _n _mean _std _max _min;
run;

data tranage;
	set tranage;
	INDEX=1;
	col=trim(left(col1));
run;

/*stats for gender*/
proc freq data=demog;
	tables gender*TrT/ out=adslgenfrq Norow nocol missing;

	/*stats for gender*/
	tables race*TRT/ out=adslracefrq Norow nocol missing;

	/*stats for race*/
run;

data genfrq;
	set adslgenfrq;
	where gender ne .;
	cntper=count || "("||trim(left(percent))||"%)";

	if gender=1 then
		_name_='M';
	else
		_name_='F';
	INDEX=2;
	rename cntper=col;
	drop count percent gender;
run;

/*STATS FOR RACE*/
data racefrq;
	set adslracefrq;
	cntper=count || "("||trim(left(percent))||"%)";

	if race=1 then
		_name_='White';
	else if race=2 then
		_name_='Black';
	else
		_name_='Other';
	INDEX=3;
	drop count percent race;
	rename cntper=col;
run;

data all;
	set tranage genfrq racefrq;
run;

proc sort ;
	by _name_;
run;

proc transpose data=all out=tranall;
	var col;
	BY _NAME_;
	ID TRT;
RUN;

** Titles and Footnotes;
%titlfoot(title1, , Table 1);
%titlfoot(title2, , DEMOGRAPHICS & BASE LINE CHARACTERISTICS);
%titlfoot(footnote1);
%titlfoot(footnote2, *Other includes Asian, Native American, and other Races.));
%titlfoot(footnote3, *To create frequencies, percentages use proc freq);
%titlfoot(footnote4, *To create n, mean, medium, min, max, standard deviation 
	use proc univariate);
** Generate Report;

proc printto print="c:\Base.txt" new;
run;

proc report data=tranall nowindows headline split='|';
	columns sectno statcode statname v0 v1 v2);
	define sectno /group noprint;
	define statcode /group noprint;
	define statname /group ' ';
	define v0 /display 'Active' width=10;
	define v1 /display 'Placebo' width=10;
	define v2 /display 'Overall' width=10;
	compute before sectno;
		line ' ';
		line @8 sectno sectno.;
	endcomp;
	quit;
run;

proc printto ;
run;

 

 

 

Super User
Posts: 23,789

Re: PROC REPORT(sorry if not posted properly)

Posted in reply to SasStudent2
I formatted your code to make it easier to read. You can do this via SAS Studio or EG (CTRL+I). Cynthia Zender is the best resource for PROC REPORT and her paper here goes over the steps required. http://www2.sas.com/proceedings/forum2008/173-2008.pdf
Super User
Posts: 13,584

Re: PROC REPORT(sorry if not posted properly)

Posted in reply to SasStudent2

@SasStudent2 wrote:

I'm not sure if this is the correct way of doing it but I keep getting errors. I am so lost at this. all help is appreciated. Thank you in advance.

  


What errors? We can't help with what we don't know. Copy the code from the log with data or proc step and any messages and paste them into a code box opened using the forum's {I} menu icon. The code box will preserve the formatting of the errors better than the main message windows here.

 

And provide some example data in the form of a data step.

 

 

SAS Super FREQ
Posts: 9,374

Re: PROC REPORT(sorry if not posted properly)

Hi:
For the type of demographic report you are asking about, there are numerous examples in user group papers and previously posted on this web site. Look here http://www2.sas.com/proceedings/forum2008/173-2008.pdf at examples 1 and 8. There are 2 examples for #1, done with PROC REPORT and 1 example for 8 done with Table Templates and DATA _NULL_. You will find the zip file of programs here: http://support.sas.com/rnd/papers/#SGF2008 -- just scroll down until you find the title -- there's a link to download the zip.

I am guessing you are getting some messages because of the combination of group and display for your variables. Typically, grouping can't be done if the other variables on the report are character variables. Usually, you need to have some kind of dummy variable that is numeric to allow grouping to take place. But that is just a guess, without data and without your full program (such as ODS statements), it's hard to guess what your errors might be.

Also, minor issue, won't cause errors, but won't get you what you want either -- some of the options you specify are LISTING only options -- headline, width and @8 will not be used by ODS destinations. As I said, no errors, but not what you probably want, either.

Cynthia
Occasional Contributor
Posts: 5

Re: PROC REPORT(sorry if not posted properly)

Posted in reply to Cynthia_sas
THANK YOU VERY MUCH, It's appreciated.
SAS Super FREQ
Posts: 356

Re: PROC REPORT(sorry if not posted properly)

Posted in reply to Cynthia_sas

Another example is the paper that John King and I worked on this  year:

 

Manipulating Statistical and Other Procedure Output to Get the Results That You Need

http://support.sas.com/papers/delgobbo-ods2018

 

Vince DelGobbo

SAS R&D

Occasional Contributor
Posts: 5

Re: PROC REPORT(sorry if not posted properly)

Thank you, I figured it out. sorry I forgot the errors.
Ask a Question
Discussion stats
  • 6 replies
  • 155 views
  • 0 likes
  • 5 in conversation