Thursday, October 21, 2010

SAS REPORTER: STARTING WITH HASH-OBJECTS PROGRAMMING-:

SAS REPORTER: STARTING WITH HASH-OBJECTS PROGRAMMING-:

STARTING WITH HASH-OBJECTS PROGRAMMING-:

/*what--learning to apply hash programming concept*/
/*how--we create two datasets master and details.We need to lookup values
from the details ds and include a column into master based on some key variable
that exists in both the ds*/

data master;
infile cards;
input car$ make$;
cards;
800 maruti
alto maruti
santro hyudai
;
proc print;

data details;
infile cards;
input car$ color$;
cards;
800 red
alto black
santro silver
;
proc print;
run;
/* Illustrate the creation of the hash table, the processing of */
/* the Master data set, and the searching of the hash table */

/*creating hash table*/

data results;
length car color $8;


/* Build the hash table */

If _N_ = 1 Then

Do;
Declare Hash MyLkup(HashExp:8,Dataset:'details');
MyLkup.DefineKey('Car');
MyLkup.DefineData('color');
MyLkup.DefineDone();
Call Missing(Car, color);
End;

/* Read an observation from the Master (transaction) file */
set master;

/* Using the value of Code from the current Master file observation, */
/* search the hash table defined above */
Rc = MyLkup.Find(Key:car);
/* Upon a successful search, write an observation to the output data set */
If Rc = 0 Then
Do;
Output Results;
End;
Run;

Send link to --

TopBlogDir.blogspot.com button Education Blog Directory Academic,  Learning & Educational Blogs - Blog Catalog Blog Directory SEO Court Directory myblog Visit blogadda.com to discover Indian blogs Add to Technorati Favorites Subscribe with Bloglines DigNow.net

Join My Community at MyBloglog!

Free Web Directory - Add Your Link
The Little Web Directory
Monster Directory A List Sites