Reading and halving a sas data set -
i have read data set of 50 numbers text file. it's in row space delimiter , in multiple uneven lines. example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
etc.
the first 25 numbers belong group 1, , 2nd 25 belong group 2. need make group variable (binary either 1 or 2), count number (1 25), , value variable holding value of number.
i stuck on how split data in half when reading it. tried use truncover did not work.
try this, replacing datalines
keyword path file:
data groups; infile datalines; format number 8. counter 2. group 1.; * not mandatory, used here order variables; retain group (1); input number @@; counter + 1; if counter = 26 do; group = 2; counter = 1; end; datalines; 192 105 435 448 160 499 184 246 388 190 316 139 146 147 192 231 449 101 216 342 399 352 122 418 280 400 187 352 321 180 425 500 320 179 105 232 105 323 132 106 255 449 186 135 472 174 119 255 308 350 run;
Comments
Post a Comment