Hello SAS community,
I successfully imported an excel sheet with the following columns, I have been asked to concatenate visitvarname (hundreds of these combos).
visit varname V0, V7 AGE V0, V7 SEX V0, V7 RACE V0, V7 HISP V0, V1, V2, V3, V5, V7, V8, V9 ZLKL/ZRKL V0, V1, V2, V3, V5, V7, V8, V9 ZROSFL/ZLOSFL V0, V1, V2, V3, V5, V7, V8, V9 ZROSFM/ZLOSFM V0, V1, V2, V3, V5, V7, V8, V9 ZROSTL/ZLOSTL V00, V01, V02, V03, V04, V05, V06, V07, V08, V09, V10, V11 WOOTSR, WOOTSL V00, V01, V02, V03, V04, V05, V06, V07, V08, V09, V10, V11 UPR, UPL; DOWNR, DOWNL
I'm hoping I can get some help to automate the process.
WANT visitvarname,
V0, V7 AGE becomes V0AGE, V7AGE
V0, V1, V2, V3, V5, V7, V8, V9 ZLKL/ZRKL becomes V0ZLKL, V1ZLKL, V2ZLKL, V3ZLKL, V5ZLKL, V7ZLKL, V8ZLKL, V9ZLKL/V0ZRKL, V1ZRKL, V2ZRKL, V3ZRKL, V5ZRKL, V7ZRKL, V8ZRKL, V9ZRKL
V00, V01, V02, V03, V04, V05, V06, V07, V08, V09, V10, V11 WOOTSR, WOOTSL becomes V00WOOTSR, V01WOOTSR, ... V11WOOTSR/V00WOOTSL, V01WOOTSL, ... V11WOOTSL
etc.
I have imported the SAS dataset but am stumped how to do the concatenation. It seems that loops and functions other than coalescec might be needed. Transposing the data into long form would seem an option but then how would I get each visitvarname combo transposed back into a single row?
data want; set have; visits_varname = coalescec (visits, varname); run;
Appreciate any help! Maggie
... View more