i want to give serial no's for reporting

i want to give serial no's for reporting

Post by naga » Fri, 18 Sep 2009 21:26:08


hi sas experts
im using data from sashelp.class
im using where statement to read 'm' data type in proc print
but im getting out put like this
The SAS
System
17:48 Thursday, June 17,
1993

Obs Name Sex Age Height Weight

1 Alfred M 14 69.0 112.5
5 Henry M 14 63.5 102.5
6 James M 12 57.3 83.0
9 Jeffrey M 13 62.5 84.0
10 John M 12 59.0 99.5
15 Philip M 16 72.0 150.0
16 Robert M 12 64.8 128.0
17 Ronald M 15 67.0 133.0
18 Thomas M 11 57.5 85.0
19 William M 15 66.5 112.0


but i want show obs 1-10sequencely for reporting only
like this
Obs Name Sex Age Height Weight

1 Alfred M 14 69.0 112.5
2 Henry M 14 63.5 102.5
3 James M 12 57.3 83.0
4 Jeffrey M 13 62.5 84.0
5 John M 12 59.0 99.5
6 Philip M 16 72.0 150.0
7 Robert M 12 64.8 128.0
8 Ronald M 15 67.0 133.0
9 Thomas M 11 57.5 85.0
10 William M 15 66.5 112.0


thanks in advance
 
 
 

i want to give serial no's for reporting

Post by jclar » Fri, 18 Sep 2009 22:37:59

aga,

The OBS variable you see in the PROC PRINT output is the observation
number from the SASHELP.CLASS data set.

If you want a serial number, you can do a couple of things:

1. Subset the data in a DATA Step, then do a PROC PRINT

Data need;
Set sashelp.class (where=(sex='M'));
Run;

Proc print data = need;
Run;

This will create a new data set named NEED with only the 10 observations
where SEX='M'. Therefore, when you print it out, the OBS variable will
be what you want (1-10).


2. Subset the data, then create a new variable for serial number

Data need;
Set sashelp.class (where=(sex='M'));
Serial = serial + 1;
* or the shorthand: serial + 1;
Run;

In this instance, you have an actual data step variable (SERIAL)
containing the serial numbers and you do not have to rely on the OBS
column in the PRINT procedure. The example below shows the NOOBS option
on PROC PRINT, which will suppress the OBS column from showing in the
output.

Proc print data = need noobs;
Run;


Hope this helps.


Jack






Jack Clark
Senior Research Analyst
phone: 410-455-6256
fax: 410-455-6850
XXXX@XXXXX.COM

University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250




Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto: XXXX@XXXXX.COM ] On Behalf Of
naga
Sent: Thursday, September 17, 2009 8:26 AM
To: XXXX@XXXXX.COM
Subject: i want to give serial no's for reporting

hi sas experts
im using data from sashelp.class
im using where statement to read 'm' data type in proc print
but im getting out put like this
The SAS
System
17:48 Thursday, June 17,
1993

Obs Name Sex Age Height Weight

1 Alfred M 14 69.0 112.5
5 Henry M 14 63.5 102.5
6 James M 12 57.3 83.0
9 Jeffrey M 13 62.5 84.0
10 John M 12 59.0 99.5
15 Philip M 16 72.0 150.0
16 Robert M 12 64.8 128.0
17 Ronald M 15 67.0 133.0
18 Thomas M 11 57.5 85.0
19 William M 15 66.5 112.0


but i want show obs 1-10sequencely for reporting only
like this
Obs Name Sex Age Height Weight

1 Alfred M 14 69.0 112.5
2 Henry M 14 63.5 102.5
3 James M 12 57.3 83.0
4 Jeffrey M 13 62.5 84.0
5 John M 12 59.0 99.5
6 Phi
 
 
 

i want to give serial no's for reporting

Post by snoopy36 » Fri, 18 Sep 2009 23:05:31


 
 
 

i want to give serial no's for reporting

Post by iebupdt » Fri, 18 Sep 2009 23:58:22

There are situations where PROC PRINT counts the observations to
produce observation numbers as in...

NOTE: Access by observation number not available. Observation numbers
will be counted by PROC PRINT.

I seems like an option to get it count observations would be nice, but
I could not find one.

Here is one way to get PROC PRINT to do what you want but it is a bit
of a "stretch", to say the least.

libname seq xport "%sysfunc(pathname(WORK,L))\class.xpt";
proc copy in=sashelp out=seq;
select class;
run;
proc print data=seq.class(where=(sex eq 'M'));
run;
 
 
 

i want to give serial no's for reporting

Post by iebupdt » Sat, 19 Sep 2009 00:24:33

Data step VIEW. Duh!

data classV / view=classV;
set sashelp.class;
where sex eq 'M';
run;
proc print data=classV;
run;