Hello everybody, I'm struggeling with some awfully structured data set that I would like to reorder in a reasonable way. The data I got looks somewhat like this data unstructured; input subject $3. dep_code_1 $3. quantity_1 dep_code_2 $3. quantity_2 dep_code_3 $3. quantity_3; datalines; s1 a1 12 a3 63 a2 17 s2 a3 2 a1 11 . s3 a1 14 a3 7 . ; run; Now here I have some departments which are internally coded as a1 a2 and a3 and some subjects s1-s3. Now for each quantity there is a line where first you see the department code followed by the quantity associated. Now in each line there are only those departments listed that are concerned by the given subject. (In addition there are further information about each subject per line, which I left out here). As you can see this structure is kind of cumbersome and I's like to reformat it so somehwat like this data structured; input subject $3. quantity_a1 quantity_a2 quantity_a3; datalines; s1 12 17 63 s2 11 2 . s3 14 . 7 ; run; Now I have the problem that e.g. I would need to read the value of dep_code_1 and of quantity_1 to do soemthing like cats("quantity_a",dep_code_1) = quantity_1 now of course this doesn't work, since cats("quantity_a",dep_code_1) does not define a proper variable name. I also tried to use a do loop and symput like this: data structured; set unstructured; do i = 1 to 3; call symput("category_name", "quantity_a"||dep_code_&i); &category_name = quantity_&i; end; run; but this again didn't work since the macro variable category_name seems not to be accesible while inside this data step. Does anybody have an idea about how this can be done? Thanks a lot in advance
... View more