SAS9 New Experience - Use of Data STEP
Don't say so much, huh, I am so happy, I installed SAS 9.1.2, I tried a small skill, and I don't know if you have trouble. For example, it needs to open the data set. A dictionary table matches the search, you may do this% let n = 1000; data _null_; set to traverse the dataset; arrary arr1 {& n}; if _n_ = 1 THEN DO; load Dictionary table data to array arr1 end; .... Match the current record to the Dictionary table run; 555, really depressed, how much is the number of groups, actually can solve this, put the number of records of the Dictionary table with a macro variable, even if this is enough Trouble, there is also a match to write it yourself, if you write it, you can decline it, it is dead, but now it is good, SAS finally provides an ultimate solution, providing 2 The objects that can be used in Data Step, is Hash Object, but have already said it, and people who have used C know that the Hash object is used to store data, and the Iterator object is used to traverse data in the Hash object. Ok, it's just like this, come to an example, quote others, not mine, but the test is passed / * Richard A. Devenezia * www.devenezia.com * Feb 11, 2003 * * Show the VALUES Of the data items of a data step hash Object in the log * /
% Macro Puthash (Hash, Vars);
% *% * Hash - Variable That References a Hash Object% * VARS - SPACE SEPARATED OF VARIABLES LINKED to TO THE DATA ITEMS OF HASH% * Separate with Pound Sign (#) TO GET VARNAME = VARVALUE FORMAT% *;
% * Generate a Random Variable Name;% Local Random Hi RC;% LET Random =% Substr (% sysfunc (Ranuni (0), 10.8), 3);% Let Hi = Hi_ & Random;% Let RC = RC_ & Random
% * Emit Data Step code That Iterate The Hash and% * Puts The Data Items VALUES IN The Log;
DECLARE HITER & HI ("& HASH"); do & rc = & hi..first () by 0 while (& rc = 0); PUT% sysfunc (translate (& vars, =, #)); & rc = & hi..next (); End; & hi..delete (); put;
% Put Warning: Values of Variables & Vars Will Change;
% mend;
Data _null_; * preip The PDV, this lazy wa y is not always recomment; if 0 THEN SET SASHELP.CLASS (OBS = 0); Declare Hash H (Dataset: 'Sashelp.class'); H.DefineKey ('Name') H.definedata ('Name', 'Age', 'Weight', 'SEX'); H.DEfinedOne ();
% Puthash (H, Name # Age # weight # sex #);% palhash (h, name agnation sex);
STOP; Run; see the output result, what else does not understand? I really don't know, I will go see SAS help, very easy