The SAS Output Delivery System and reporting techniques

Using the N statistic in PROC REPORT.

Reply
Occasional Contributor
Posts: 7

Using the N statistic in PROC REPORT.

Hi,

I am using the N statistic in one of my requirement.

My i.p files look like the one below :

ID Name
1111 Murali
2222 Nick

ID DESCRIPTION
1111 Description 1
2222 Description 2

The final report which I try to bring out of PROC REPORT looks like this :

ID DESCRIPTION N
1111 DESCRIPTION 1 2
2222 DESCRIPTION 2 1

Column N indicates, the number of records for each ID.

The PROC REPORT i coded was :

PROC REPORT DATA=MERGED NOCENTER NOWD HEADLINE HEADSKIP MISSING;
COLUMN ID NAME N;
DEFINE SDC / GROUP FORMAT=£4. 'ID';
DEFINE SDCDESC / GROUP FORMAT=£40. 'NAME';

Everything works fine. But the third column heading is coming up as 'N'. I want it to be TOTAL. I am not sure how I can change it.

I want the report to be :

ID DESCRIPTION TOTAL
1111 DESCRIPTION 1 2
2222 DESCRIPTION 2 1

I would be very very happy if someone can help in this.

Thanks....
N/A
Posts: 0

Re: Using the N statistic in PROC REPORT.

Posted in reply to m_u_r_a_l_i
Your column definition :
DEFINE SDCDESC / GROUP FORMAT=£40. 'NAME'
will name the column with a label of "NAME", not "DESCRIPTION". Be careful when copying or creating dummy code that you don't lose the sense.

The quoted value will label the column, and providing a definition for the N column will give you the column label you require.

Kind regards

David
Occasional Contributor
Posts: 7

Re: Using the N statistic in PROC REPORT.

Posted in reply to deleted_user
Hey,

Thanks Daniel. Please find the correct one below :
PROC REPORT DATA=MERGED NOCENTER NOWD HEADLINE HEADSKIP MISSING;
COLUMN ID NAME N;
DEFINE ID / GROUP FORMAT=£4. 'ID';
DEFINE NAME / GROUP FORMAT=£40. 'NAME';

Now when I define, N, it says N is not a part of the MERGED dataset ! So it doesnt work if I define N.
Occasional Contributor
Posts: 7

Re: Using the N statistic in PROC REPORT.

Posted in reply to deleted_user
Sorryyyyy.

It worked !
Ask a Question
Discussion stats
  • 3 replies
  • 140 views
  • 0 likes
  • 2 in conversation