<p>Try the following code to se if you can find the number of blocks (the number of datasets to be created) and <br/>the number of variables in each block (dataset). These numbers are saved in macro variables: <br/>Num_of_Datasets, NVar_in_Dataset1, NVar_in_Dataset2, ..., and can be used in other macros for input the data.</p><p><br/>data _NULL_;<br/> infile 'D:\MySAS\RawData.txt'; <br/> if _N_ = 1 then Num_block = 1;<br/> retain Num_block Num_var;<br/> input line $80.;<br/> if line = null then Num_block +1;<br/> dataset_name='Dataset'!!trim(left(Num_block));<br/> if line ^= null then Num_var = count(line, ',')+1;<br/> call symput('NVar_in_Dataset'!!trim(left(Num_block)), Num_var);<br/> call symput('Num_of_Datasets', Num_block);<br/>run;<br/>%put _user_; /* to check the number saved in the macro variables */</p><p></p><br>xmok77
金钱 +100
奖励 2009-3-7 11:08:30