These automatic variables are not ‘always’ available for data step as other _n_ ,_error_,_character_, _numeric_ which are created for every data step.
First. And last. Are created during ‘by’ group processing only i.e when we use a by statement.first. has value 1 for first value of by group and 0 for the rest .similarly last. Is 1 for the last occurrence value in the by group and 0 for all other in that by group.
For example---
Consider the code---
Data data1;
Input id age month sal;
Cards;
001 23 110000
001 23 2 20000
002 21 1 10000
003 24 114000
003 24 2 13000
;
Run;
/*we want count of obs with duplicate id number*/
Data data2;
Set data1;
By id; /*first. And last. Created*/
If first. Then n_id=0; /* sets n_id 0 for new id value*/
N_id+1; /*increments by 1 for every recurrence of id*/
If last. Then output ; /*outputs on occurrence of last id in the group*/
Run;
Output of data2---
id age month sal n_id
1 23 2 20000 2
2 21 1 10000 1
3 24 2 13000 2
hi, let us study how to generate different report formats in sas using different techniques and sas procedures..we will also learn how to customize the layout of the reports as per the requirement using the power of sas.. Discalimer-:This blog is for sharing the knowledge that i have gained .i do not calim the ownership of the original content that is included in the blog.SAS is a trademark of SAS ,usa.
Sunday, July 12, 2009
Send link to --
SEO Court Directory
myblog
Free Web Directory - Add Your Link
The Little Web Directory
Monster Directory A List Sites
The Little Web Directory
Monster Directory A List Sites