How to download and try this example
Usage: pl processdata.htm // This is a test suite for proc processdata // Run this script and examine the stderr output (texts of correct results are embedded)
#write stderr #+ #+ ===================== #+ action: accumulate #endwrite #proc getdata data: A21 3 A22 5 A23 2 A24 1 #proc processdata action: accumulate field: 2 showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ A21|3| #+ A22|8| #+ A23|10| #+ A24|11| #+ #+ ===================== #+ action: count (1 field) #endwrite #proc getdata data: 062698 062698 062898 070198 070198 070198 070498 #proc processdata action: count field: 1 showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 062698|2| #+ 062898|1| #+ 070198|3| #+ 070498|1| #+ #+ ===================== #+ action: count (2 fields) #endwrite #proc getdata data: 062698 4 062698 6 062898 3 070198 2 070198 4 070198 3 070498 2 #proc processdata action: count fields: 1 2 showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 062698|10| #+ 062898|3| #+ 070198|9| #+ 070498|2| #+ #+ ===================== #+ action: count (2 fields, tabulating on 1 week bins) #endwrite #proc usedata originaldata: yes #proc processdata action: count fields: 1 2 binsize: week showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 062498|10| #+ 070198|14| #+ #+ ===================== #+ action: count (1 field, tabulating on numeric bins) #endwrite #proc getdata data: 2 3 4 5 7 9 12 15 19 23 #proc processdata action: count fields: 1 binsize: 5 binmod: low showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 0|3| #+ 5|3| #+ 10|1| #+ 15|2| #+ 20|1| #+ #+ ===================== #+ action: echo #endwrite #proc getdata data: A 252 A 357 B 377 C 281 C 118 #proc processdata action: echo showresults: yes select: @@1 != B #endproc #write stderr #+ .... the above result should look like this: #+ A|252| #+ A|357| #+ C|281| #+ C|118| #+ #+ #+ ===================== #+ action: numberrows #endwrite // use the same data as above... #proc usedata originaldata: yes #proc processdata action: numberrows showresults: yes select: @@2 < 300 #endproc #write stderr #+ .... the above result should look like this: #+ 1|A|252| #+ 2|C|281| #+ 3|C|118| #+ #+ #+ ===================== #+ action: join #endwrite #proc getdata data: 001 X 4.3 001 Y 5.2 002 X 3.2 002 Y 2.9 003 Y 3.3 004 X 7.2 005 Y 1.9 #proc processdata action: join field: 1 leftselect: @@2 = X rightselect: @@2 = Y showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 001|X|4.3|001|Y|5.2| #+ 002|X|3.2|002|Y|2.9| #+ #+ ===================== #+ action: leftjoin #endwrite #proc usedata originaldata: yes #proc processdata action: leftjoin field: 1 leftselect: @@2 = X rightselect: @@2 = Y showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 001|X|4.3|001|Y|5.2| #+ 002|X|3.2|002|Y|2.9| #+ 004|X|7.2|=|=|=| #+ #+ ====================== #+ action: rightjoin #endwrite #proc usedata originaldata: yes #proc processdata action: rightjoin field: 1 leftselect: @@2 = X rightselect: @@2 = Y showresults: yes missingdatacode: #endproc #write stderr #+ .... the above result should look like this: #+ 001|X|4.3|001|Y|5.2| #+ 002|X|3.2|002|Y|2.9| #+ |||003|Y|3.3| #+ |||005|Y|1.9| #+ #+ ======================== #+ action: percents #endwrite #proc getdata data: A 8 B 44 A 4 B 87 A 3 B 24 A 5 B 99 #proc processdata action: percent fields: 2 4 showresults: yes #endproc #write stderr #+ totals:@TOTALS #+ .... the above result should look like this: #+ A|40|B|17.3228| #+ A|20|B|34.252| #+ A|15|B|9.44882| #+ A|25|B|38.9764| #+ totals:20,254 #+ #+ ======================= #+ action: raccumulate #endwrite #proc getdata data: AA 3 6 1 BB 1 0 4 CC 2 n/a 1 #proc processdata action: raccumulate fields: 2 3 4 showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ AA|3|9|10| #+ BB|1|1|5| #+ CC|2|2|3| #+ #+ ======================== #+ action: reverse #endwrite #proc getdata data: AXB 34 BYA 22 CES 52 DIF 14 #proc processdata action: reverse showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ DIF|14| #+ CES|52| #+ BYA|22| #+ AXB|34| #+ #+ ========================= #+ action: rotate #endwrite #proc getdata data: A 2 4 6 B 3 6 9 #proc processdata action: rotate showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ A|B| #+ 2|3| #+ 4|6| #+ 6|9| #+ #+ ========================== #+ action: segment (1 data field) #endwrite #proc getdata data: 062698 A 062698 B 062698 C 070198 D 070198 E 070198 F 070498 G #proc processdata action: segment field: 1 showresults: yes #endproc #write stderr #+ ..... the above result should look like this: #+ 062698|1|3| #+ 070198|4|6| #+ 070498|7|7| #+ #+ ======================== #+ action: segment (2 data fields) #endwrite #proc usedata originaldata: yes #proc processdata action: segment field: 1 2 showresults: yes #endproc #write stderr #+ ..... the above result should look like this: #+ 062698|A|C| #+ 070198|D|F| #+ 070498|G|G| #+ #+ ========================== #+ action: segmentb (1 data field) #endwrite #proc getdata data: 062698 A 062698 B 062698 C 070198 D 070198 E 070198 F 070498 G #proc processdata action: segmentb field: 1 showresults: yes #endproc #write stderr #+ ..... the above result should look like this: #+ 062698|1|4| #+ 070198|4|7| #+ 070498|7|7| #+ #+ ======================== #+ action: segment (2 data fields) #endwrite #proc usedata originaldata: yes #proc processdata action: segmentb field: 1 2 showresults: yes #endproc #write stderr #+ ..... the above result should look like this: #+ 062698|A|D| #+ 070198|D|G| #+ 070498|G|G| #+ #+ ========================== #+ action: summary #endwrite #proc getdata file: summarytest.dat #proc processdata action: summary valfield: 5 fields: 1 2 3 select: @@3 = f showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 2909|129S1/SvImJ|f|0.75|0.790569|0.25|10|0|2|7.5| #+ 2909|A/J|f|1.4|0.516398|0.163299|10|1|2|14| #+ 2909|BALB/cJ|f|0.8|0.537484|0.169967|10|0|2|8| #+ 2909|BPH/2J|f|1.75|0.978945|0.30957|10|0.5|4|17.5| #+ 2909|BPL/1J|f|1.5|0.707107|0.223607|10|1|3|15| #+ 2909|BPN/3J|f|0.9|0.459468|0.145297|10|0.5|2|9| #+ 2909|BTBR_T+_tf/J|f|0.5|0|0|3|0.5|0.5|1.5| #+ 2909|C3H/HeJ|f|1.38889|0.781736|0.260579|9|0.5|3|12.5| #+ 2909|C57BL/10J|f|1.6|0.843274|0.266667|10|1|3|16| #+ 2909|C57BL/6J|f|1.9|0.737865|0.233333|10|1|3|19| #+ 2909|C57BLKS/J|f|0.75|0.273861|0.111803|6|0.5|1|4.5| #+ 2909|C57BR/cdJ|f|1|0|0|1|1|1|1| #+ #+ ========================= #+ action: summaryplus #endwrite #proc usedata originaldata: yes #proc processdata action: summaryplus valfield: 5 fields: 1 2 3 select: @@3 = f && @@2 like B* showresults: yes #endproc #write stderr #+ .... the above result should look like this: #+ 2909|BALB/cJ|f|0.8|0.537484|0.169967|10|0|2|8|0|0.5|0.75|1|2| #+ 2909|BPH/2J|f|1.75|0.978945|0.30957|10|0.5|4|17.5|0.5|1|2|2|4| #+ 2909|BPL/1J|f|1.5|0.707107|0.223607|10|1|3|15|1|1|1|2|3| #+ 2909|BPN/3J|f|0.9|0.459468|0.145297|10|0.5|2|9|0.5|0.5|1|1|2| #+ 2909|BTBR_T+_tf/J|f|0.5|0|0|3|0.5|0.5|1.5|0.5|0.5|0.5|0.5|0.5| #+ #+ ============================= #+ action: stats #endwrite #proc getdata data: 8 A 9 B 10 C 11 D #proc processdata action: stats field: 1 tagfield: 2 #endproc #write stderr #+ mean=@MEAN sd=@SD n=@N min=@MIN min_id=@MIN_ID max=@MAX max_id=@MAX_ID nmissing=@NMISSING total=@TOTAL #+ #+ ... the above result should look like this: #+ mean=9.5 sd=1.29099 n=4 min=8 min_id=A max=11 max_id=D nmissing=0 total=38 #+ #+ =============================== #+ action: totals #endwrite #proc getdata data: 1 3 5 2 4 6 #proc processdata action: totals fields: 1 2 3 resultformat: %.3f #endproc #write stderr #+ @TOTALS #+ #+ ... the above result should look like this: #+ 3.000,7.000,11.000 #+ #+ =========== end of test ================ #endwrite