Administrator
|
This post was updated on .
** THIS POST HAS BEEN CORRECTED IN A LATER POSTING. PLEASE IGNORE AND SCROLL ;-) **
Deliberately left uncommented and all smooshed together to encourage the RTFM thing (or at least reading through the code ;-) Happy turkey slaughter day to all. This is related to a number of recent posts. ----- DEFINE XTabsToSav ( !POS !CHAREND ("/") / !POS !CMDEND !DEFAULT ('omsXTABout')). DATASET DECLARE !2. OMS / SELECT TABLES TEXTS/ IF COMMANDS=['Crosstabs']/ DESTINATION VIEWER=NO. OMS / SELECT TABLES / IF COMMANDS=['Crosstabs'] SUBTYPES=['Crosstabulation'] / DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE=!2 . CROSSTABS !LET !VCopy=!TAIL(!1) !DO !R !IN(!1) !CONCAT(!R," BY ",!VCopy, " /")!LET !VCopy=!TAIL(!VCopy)!IF (!VCopy=!NULL) !THEN !BREAK !IFEND !DOEND. OMSEND. DATASET ACTIVATE !2. COMPUTE @=0. MATCH FILES / FILE * / KEEP TableNumber_ TO Var3 @ ALL. COMPUTE @junk@=0. OMS/ SELECT TABLES TEXTS / IF COMMANDS=['Variables to Cases']/ DESTINATION VIEWER=NO. VARSTOCASES / ID=id/ MAKE trans1 FROM @ TO @junk@/ INDEX=Index1(trans1) / KEEP= Label_ Var1 Var2 . OMSEND. DELETE VARIABLES id . SELECT IF NOT (ANY(index1,"Total","@junk@","@")) AND Var1 NE "Total". ALTER TYPE index1 (A64). COMPUTE index1=CONCAT('v',SUBSTR(index1,2)). OMS/ SELECT TABLES TEXTS/ IF COMMANDS=['Cases to Variables' ]/ DESTINATION VIEWER=NO. CASESTOVARS/ ID=Label_ / INDEX=Index1 var2/ DROP Var1. OMSEND. !ENDDEFINE. XTabsToSav V01 V02 V03 V04 V05 V06 V07 V08 V09 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 / OMSXTABOut.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
EDITED!!! Previously the file was going WIDE because of extended variable names form OMS.
I had initially kludged by truncation but later realized that would not in general work... Stuff here has been corrected ;-) NOTE TO SELF! ALWAYS RUN MOST RECENT VERSION BEFORE POSTING ;-) Added: "ALTER TYPE index1 (A64). COMPUTE index1=CONCAT('v',CHAR.SUBSTR(index1,2)). COMPUTE #=CHAR.INDEX(Index1,"_"). IF # GT 0 Index1=CHAR.SUBSTR(Index1,1,#-1). " ----- DEFINE XTabsToSav ( !POS !CHAREND ("/") / !POS !CMDEND !DEFAULT ('omsXTABout')). DATASET DECLARE !2. OMS / SELECT TABLES TEXTS/ IF COMMANDS=['Crosstabs']/ DESTINATION VIEWER=NO. OMS / SELECT TABLES / IF COMMANDS=['Crosstabs'] SUBTYPES=['Crosstabulation'] / DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE=!2 . CROSSTABS !LET !VCopy=!TAIL(!1) !DO !R !IN(!1) !CONCAT(!R," BY ",!VCopy, " /")!LET !VCopy=!TAIL(!VCopy)!IF (!VCopy=!NULL) !THEN !BREAK !IFEND !DOEND. OMSEND. DATASET ACTIVATE !2. COMPUTE @=0. MATCH FILES / FILE * / KEEP TableNumber_ TO Var3 @ ALL. COMPUTE @junk@=0. OMS/ SELECT TABLES TEXTS / IF COMMANDS=['Variables to Cases']/ DESTINATION VIEWER=NO. VARSTOCASES / ID=id/ MAKE trans1 FROM @ TO @junk@/ INDEX=Index1(trans1) / KEEP= Label_ Var1 Var2 . OMSEND. DELETE VARIABLES id . SELECT IF NOT (ANY(index1,"Total","@junk@","@")) AND Var1 NE "Total". ALTER TYPE index1 (A64). COMPUTE index1=CONCAT('v',CHAR.SUBSTR(index1,2)). COMPUTE #=CHAR.INDEX(Index1,"_"). IF # GT 0 Index1=CHAR.SUBSTR(Index1,1,#-1). OMS/ SELECT TABLES TEXTS/ IF COMMANDS=['Cases to Variables' ]/ DESTINATION VIEWER=NO. CASESTOVARS/ ID=Label_ / INDEX=Index1 var2/ DROP Var1. OMSEND. !ENDDEFINE. XTabsToSav V01 V02 V03 V04 V05 V06 V07 V08 V09 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 / OMSXTABOut.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |