----
Also known as [[Chang Y. Chung|http://changchung.com/]].
window.onClickToolbarCloseOthers = function(e) {\n if (!e) var e = window.event;\n clearMessage();\n if(this.parentNode.id)\n closeAllOtherTiddlers(this.parentNode.id.substr(7));\n e.cancelBubble = true;\n if (e.stopPropagation) e.stopPropagation();\n return(false);\n}\n\nfunction closeAllOtherTiddlers(thisTitle) {\n clearMessage();\n var place = document.getElementById("tiddlerDisplay");\n var tiddler = place.firstChild;\n var nextTiddler;\n while(tiddler) {\n nextTiddler = tiddler.nextSibling;\n if(tiddler.id) {\n if(tiddler.id.substr(0,7) == "tiddler") {\n var title = tiddler.id.substr(7);\n if(!document.getElementById("editorWrapper" + title) && title != thisTitle) {\n place.removeChild(tiddler);\n }\n }\n }\n tiddler = nextTiddler;\n }\n window.scrollTo(0,0);\n}\n\nconfig.views.wikified.toolbarCloseOthers = {text: "close others", tooltip: "Close all tiddlers except this one"};\n\nwindow.createTiddlerToolbar_orig_mptw_closeothers = window.createTiddlerToolbar;\nwindow.createTiddlerToolbar = function(title,isEditor) {\n createTiddlerToolbar_orig_mptw_closeothers(title,isEditor);\n var theToolbar = document.getElementById("toolbar" + title);\n var lingo = config.views.wikified;\n if(!isEditor) {\n var newButton = createTiddlyButton(theToolbar, lingo.toolbarCloseOthers.text, lingo.toolbarCloseOthers.tooltip, onClickToolbarCloseOthers);\n var newSpacer = insertSpacer(theToolbar);\n\n secondButton = theToolbar.childNodes[3];\n\n\n theToolbar.insertBefore(newSpacer,secondButton);\n theToolbar.insertBefore(newButton,newSpacer);\n\n }\n}
!General\n* don't comment the obvious; do comment the non-obvious\n* comments and code //must// agree\n* don't rely on comments to explain messy code -- write a cleaner code\n* some people develop a "Literary Programming" style with extensive comments (organized with special markers or tags) intermixed with source code. The source code then is processed to produce nicely formatted document(s). (e.g. perldoc, javadoc,...)\n\n!Stata Specific\n* four ways to comment in a do-file:\n** line begins with a {{{*}}} (works in the interactive session also)\n** something in between {{{/* */}}}\n** anything after {{{(blank)//}}} until the end of the line\n** anything after {{{(blank)///}}} until the end of the line\n* use one kind for comments; use another for temporarily commentting some code out\n\n\n
[[Data]]\n[[DataManagement]]\n[[DataLifeCycle]]\n[[VarName]]\n[[Labels]]\n[[Comments]]\n[[Header]]\n[[FileName]]\n[[MasterDo]]\n[[Directory]]\n[[SharingData]]\n
!Tips and tricks on Data Management
!Data as Organized Measurements\n* Measure or the instrument: ruler, scale, or survey question\n* Over multiple "units of observation": items, people, person-year's, households\n* Organized as a matrix (row, column), table(record, field), dataset(observation, variable)\n| |! var1|! var2|! var3|! ... |\n|!obs1| 1 | 2 | 3 | |\n|!obs2| 4 | 5 | 6 | |\n|!obs3| 7 | 8 | 9 | |\n|!obs4| 10 | 11 | 12 | |\n|!... | | | | |\n\n!Stata Specific\n* describe auto.dta\n{{{\n. sysuse auto\n(1978 Automobile Data)\n\n. des\n\nContains data from C:\sProgram Files\sStata9\sado\sbase/a/auto.dta\n obs: 74 1978 Automobile Data\n vars: 12 13 Apr 2005 17:45\n size: 3,478 (99.9% of memory free) (_dta has notes)\n-------------------------------------------------------------------------------\n storage display value\nvariable name type format label variable label\n-------------------------------------------------------------------------------\nmake str18 %-18s Make and Model\nprice int %8.0gc Price\nmpg int %8.0g Mileage (mpg)\n...\ngear_ratio float %6.2f Gear Ratio\nforeign byte %8.0g origin Car type\n-------------------------------------------------------------------------------\nSorted by: foreign\n}}}\n* the actual data are:\n{{{\n. clist make price mpg ... gear_ratio foreign, nolabel\n}}}\n| |!make|!price|!mpg|!...|!gear_ratio|!foreign|\n|!1.|AMC Concord | 4,099| 22|...| 3.58| 0|\n|!2.|AMC Pacer | 4,749| 17|... | 2.53| 0|\n|!3.|AMC Spirit | 3,799| 22|... | 3.08| 0|\n|!4.|Buick Century| 4,816| 20|... | 2.93| 0|\n|!5.|Buick Electra | 7,827| 15|... | 2.41| 0|\n|!6.|Buick ~LeSabre| 5,788| 18|...| 2.73| 0|\n|!7.|Buick Opel | 4,453| 26|...| 2.87| 0|\n|!8.|Buick Regal | 5,189| 20|...| 2.93| 0|\n|!...|||||||\n\n* You can access any //measurement// directly, e.g.\n{{{\n. di make[1]\nAMC Concord\n\n. di price[3]\n3799\n}}}\n* In fact, many stata commands implicitly loop over observations, e.g.\n{{{\ngen priceInK = price / 1000\n}}}\n\nis (roughly) equivalent to:\n{{{\ngen priceInK = .\nlocal N = _N\nforvalues obs = 1/`N' {\n replace priceInK = price[`obs'] / 1000 in `obs'\n}\n}}}\n
!1 Proposal Planning and Writing\n* consider special archival challenges (consent, confidentiality, etc.)\n* budget for sharing and archiving\n!2 Project Start-up\n* plan data management\n* make decisions about what and how to document\n* pre- (or pilot)-tests\n!3 Data Collection and File Creation\n* follow best practices\n* backup\n* document as you go\n!4 Data Analysis\n* manage master data files and work (analysis) files\n* set up and maintain appropriate file structure and organization\n!5 Preparing Data for Sharing with Others\n* address disclosure risks\n* contact data archive for advice\n!6 Depositing Data to Archive\n* complete paper work\n* comply with dissemination standards and formats\n!7 Archival Activities\n* evaluate collection\n* additional confidentiality review (optional)\n* data and meta-data processing\n* possible data enhancement and additional documentation\n* preservation, delayed dissemination, publicity\n* support for data users\n* preservation\n----\nFrom "The data life cycle" p.vii in [[Guide to Social Science Data Preparation and Archiving|http://www.icpsr.umich.edu/DSDR/dsdr-guide.pdf]] by Data Sharing for Demographic Research([[DSDR|http://www.icpsr.umich.edu/DSDR/index.html]] 1997)
![[DAMA|http://www.dama.org/public/pages/index.cfm?pageid=71]] definition\n* "Data (Resource) Management is the development and execution of architectures, policies, practices and procedures that properly manage the full data lifecycle needs of an enterprise."\n![[Stata|http://stata.com/help.cgi?y_dm]] Definition\n* "Data management for statistical applications refers not only to classical data management -- sorting, merging, appending, and the like -- but also to data reorganization because the statistical routines you will use assume that the data are organized in a certain way." (see [DM] ''data management'')\n
[[Welcome]]
!General\n* many different ways to organize files into directories.\n** one project, one directory, all the files -- Bill Gould\n** according to //analysis steps//:\n{{{\nproject (master.do file may reside here)\n - step01 (do, log, dta, user doc files)\n - step02 (do, log, dta, user doc files)\n ...\n}}}\n** according to //datasets// and then //analysis steps//:\n{{{\nproject\n - mothers\n --- step01\n --- step02\n ...\n - fathers\n --- step01\n --- step02\n ...\n}}}\n** according to //file types// -- this may be ''problematic''!\n{{{\nproject\n - do files (for all steps, including the master.do file)\n - log files (...)\n - excel files\n - word files\n - user documentation files \n}}}\n!Stata Specific\n** "current working directory" is the //default// directory where stata reads files-from and writes-files to. \n** to see which directory is the current working directory: {{{cd}}} or {{{pwd}}}\n{{{\n. cd\nz:\s\n\n. pwd\nz:\s\n}}}\n** change the current working directory:\n{{{\n. cd "z:\smyProject"\n}}}\n** stata 8 bug on network directory use three-back slashes\n{{{\n. cd "\s\s\sopr\sshares\sresearch"\n\s\sopr\sshares\sresearch\n}}}\n
!General\n* make it meaningful (e.g. don't do: {{{final.do}}}, {{{final-final.do}}}, {{{final_last.do}}})\n* Short but not-too short\n* Try to avoid special characters\n* Consider adopting a file naming convention and sticking to it\n** [[World Fertility Survey|http://opr.princeton.edu/archive/wfs/]] uses two-chars for country, two-chars for type, two-digits for release number. (e.g. {{{JMSR03.DAT}}} -- Jamaica, Standard Record, the third release)\n** prefix "an" for do files that analyze data and "cr" for creating a dataset. (e.g. {{{crxyz.do}}} creates a data set {{{xyz.dta}}}. Another do file, {{{anxyz.do}}} analyze the dataset. The results are saved in {{{anxyz.log}}}. Temporarily saved dataset names have {{{tmp}}} prefix.\n** prefix do files with two-digit number followed by short description. (e.g. {{{01createAna.do}}} {{{02recodeVars.do}}} {{{03fitModels.do}}})
!General\nit is convenient to have a source code //template// with some kinds of headers/footers so that we can document the source code in a standardized way.\n\n!Stata Specific\nan example:\n{{{\n clear\n version 9\n cap log close\n cap log using make_ana2.log, replace text\n set more off\n\n* filename : make_ana2.do\n* purpose : to create an analysis data set, ana2\n* input : \s\sresearch\sproject\smaster.dta\n* output : \s\sresearch\sproject\smyDir\sana2.dta\n* first-written : by me on 2005-10-15\n* last modified : by me on 2005-10-19 added two more derived variables\n\n cd \s\sresearch\sproject\smyDir\n use ..\smaster.dta\n\n* check assumptions\n isid pid\n assert sex=="M" | sex=="F"\n\n* work goes here\n\n ...\n\n* save\n save ana2, replace\n\n* done\n log close\n set more on\n}}}\n
!General\n* use'em!\n* all the variables, all the codes, (and datasets) should be labeled. (e.g. Province code in WFS Indonesia 1976)
.gradient {padding:1em;}\n\n.viewer code, .viewer pre {\n color: #000;\n font-family:'Courier New',monospace;\n font-size:95%;\n font-weight: bold;\n border-style:solid;\n border-width:thin;\n border-color: gray;\n padding: 1px;\n line-height:1.2em;\n background-color:#f8f8f8;\n}\n\n.titleBox { \n font-size:120%; font-weight:bold; \n}\n\n\n#sidebarOptions .sliderPanel {\n background-color: #9b9;\n}\n\n.editor textarea { height:20em; }\n\n#sidebarOptions .tiddlyLink { color:#eef; padding: 0.3em 0.2em 0.3em 1em; display:block;}\n#sidebarOptions .tiddlyLink:hover { color:#fff; background:#252;}\n/* need these to override the above for the options slider */\n#sidebarOptions .sliderPanel .tiddlyLink {color:#242;display:inline;padding:0;}\n#sidebarOptions .sliderPanel .tiddlyLink:hover {color:#242; background:#dfd;}\n\n\n\n#sidebarTabs .tabContents { overflow:visible; white-space:normal; width:auto; }\n\ndiv#mainmenu hr {margin:0px;padding:0px;padding-top:10px;\n border-style:none;\n border-width:1px;\n border-color:#ccc;\n border-bottom-style:solid;\n}\n\n/* colour scheme begin */ \ndiv#titleLine { background:#135;}\ndiv#sidebarOptions { background:#696; }\ndiv#sidebarOptions .button { color:#eef;}\ndiv#sidebarOptions .button:hover { color:#fff; background:#252;}\n\n\n\n\ndiv#mainmenu .tiddlyLink { font-weight:bold;color:#369; }\ndiv#mainmenu .tiddlyLink:hover { background:#369;color:white; }\ndiv#mainmenu .button { font-weight:bold; color:#363; }\ndiv#mainmenu .button:hover { background:#363;color:white; }\ndiv.viewer a.tiddlyLink { color:#369; }\ndiv.viewer a.tiddlyLink:hover { background:#acd; }\ndiv.footer a.tiddlyLink { color:#369; }\ndiv.footer a.tiddlyLink:hover { background:#acd; }\n.editorFooter a.button, .tiddler .button { color: #369; background:#eee; }\n.editorFooter a.button:hover, .tiddler .button:hover { color: #fff; background: #369; }\n.editorFooter a.button:active, .tiddler .button:active { color: #fff; background: #369; }\n.editorFooter a:link { color: #369; } \n#popup {color:#eee; background:#369;}\n#popup a {color:#fff; background:#369; }\n#popup a:hover {color:black; background:#eee;}\n#mainMenu .externalLink { color:#252; }\n#mainMenu .externalLink:hover { color:white;background:#696; }\n.tiddler .externalLink { color:#252; }\n.tiddler .externalLink:visited { color:#252; }\n.tiddler .externalLink:hover { color:#252;background:#ada; }\n.viewer a:link { color: #252; } \n.viewer a:visited { color: #252; } \n.viewer a:hover { color:#252; background:#ada; }\n#titleLine a {color:white;}\n\n.viewer .tabSelected {background-color: white;font-weight:bold; border:solid 2px #ddd;border-bottom-color:white;}\n.viewer .tabContents {background-color: white; border:solid 2px #ddd;}\n.viewer .tabset {background-color:white;}\n.viewer .tabUnselected {color:#999;background-color:#ddd;}\n\n#sidebarTabs .txtMainTab .tabSelected {color: white;background-color: #69c;font-weight:bold;}\n#sidebarTabs .txtMainTab .tabContents {background-color: #69c;}\n#sidebarTabs .txtMainTab .tabset {background-color:#696;}\n#sidebarTabs .txtMainTab .tabUnselected {color:#ace;background-color:#369;}\n\n#sidebarTabs .txtMoreTab .tabSelected {color:white;background-color: #7ad;font-weight:bold;}\n#sidebarTabs .txtMoreTab .tabUnselected {color:#ace;background-color:#369;}\n#sidebarTabs .txtMoreTab .tabContents {background-color: #7ad;}\n#sidebarTabs .txtMoreTab .tabset {background-color: #69c;}\n\n#sidebarTabs .tabContents .tiddlyLink {color: #135;}\n#sidebarTabs .tabContents .tiddlyLink:hover {background-color: #eee;color: black;}\n#sidebarTabs .tabContents .button {color: #eee;}\n#sidebarTabs .tabContents .button:hover {color: #white;background-color: #252;}\n\n\n\n/* colour scheme end */\n\n#displayArea {\n margin-right: 15.5em;\n margin-left: 13em;\n}\n\n// this works great in firefox but breaks something with ie. help??\n// .toolbar { float:right; }\n\n\n.viewer h1,\n.viewer h2,\n.viewer h3,\n.viewer h4,\n.viewer h5 { font-family: 'Trebuchet MS' Arial sans-serif; background:transparent;}\n\n.viewer h1 { font-size:1.2em; }\n.viewer h2 { font-size:1.1em; }\n.viewer h3 { font-size:1.0em; }\n.viewer h4 { font-size:0.9em; }\n.viewer h5 { font-size:0.8em; }\n\n.viewer h1 {border-bottom:solid #eee 2px;}\n\nbody {\n background:#eee;\n}\n\ndiv.tiddler {\n font-size:120%;\n background:white;\n border-top:solid #ccc 2px;\n border-left:solid #ccc 2px;\n border-bottom:solid #aaa 2px;\n border-right:solid #aaa 2px;\n margin-bottom:5px;\n padding-bottom:10px;\n}\n\n\ndiv.title {\n font-family:'Trebuchet MS' Arial sans-serif;\n font-size:150%;\n}\n\ndiv.editor input,\ndiv.editor textarea {\n background:#ffe;\n border:solid #aa9 2px;\n margin:4px;\n}\n\ndiv#adsense {\n background:#ffd; border:solid 2px #bb9; text-align:center;\n margin-bottom:0.5em; \n padding:0.7em; \n overflow:hidden;\n}\n\n@media print {\n div.tiddler {border:none white 0px; border-top:solid #bbb 1px;}\n div.tagged {border:none white 0px;}\n #titleLine { display:none; }\n #displayArea { margin-right: 0px; margin-left: 0px; }\n .toolbar { display:none; }\n div#adsense { display:none; }\n}\n\n
[[About]]\n----\n<<slider Contents Contents Contents "Click here to see the Contents">>\n----\n[[Home|http://changchung.com/]]\n[[Changarilla|http://changchung.com/changarilla/]]\n----\n<<newTiddler>>
!Stata Specific\n* use master do file which just calls other do files sequentially. It provides great overview and it makes replication a breeze.\n{{{\n* master.do\n\n* extract some vars from the master\n do extract.do\n\n* create some new vars\n do createVars.do\n\n* make descriptive tables\n do tables.do\n\n* run models\n do models.do\n}}}\n* Bill Gould's Stata Netcourse 151 (Programming) lecture1 note pages 14-40 "organizing do-files." (Guess who Bill Gould is?)\n
window.onClickToolbarNewHere = function(e) {\n if (!e) var e = window.event;\n clearMessage();\n if(this.parentNode.id) {\n displayTiddler(this.parentNode,"New Tiddler",2,null,null,false,false);\n tagBox = document.getElementById("editorTagsNew Tiddler"); \n var tagString = this.parentNode.id.substring(7);\n if (!window.commafyTags) // we aren't using comma separated tags plugin (commafyTags is a function)\n if(tagString.indexOf(" ") != -1)\n tagString = "[[" + tagString + "]]";\n tagBox.value = tagString;\n }\n e.cancelBubble = true; // do I need this?\n if (e.stopPropagation) e.stopPropagation(); // do I need this?\n return false;\n}\n\nconfig.views.wikified.toolbarNewHere = {\n text: "new here",\n tooltip: "Create a new tiddler tagged as this tiddler"\n};\n\nwindow.createTiddlerToolbar_mptw_newhere = window.createTiddlerToolbar;\n\nwindow.createTiddlerToolbar = function(title,isEditor) {\n // first create regular toolbar\n createTiddlerToolbar_mptw_newhere(title,isEditor);\n\n if(!isEditor) {\n // now add extra button\n var theToolbar = document.getElementById("toolbar" + title);\n var lingo = config.views.wikified;\n createTiddlyButton(theToolbar, lingo.toolbarNewHere.text, lingo.toolbarNewHere.tooltip, onClickToolbarNewHere);\n insertSpacer(theToolbar); // in case we wanna add any more buttons after this one\n }\n}
!General\n* "I'm just keeping it very simple." -- [[Craig Newmark|http://www.mistersf.com/sanfran/sanfrancraig.htm]]\n* at some point, stop modifying -- lock it up or impose the freeze (make the dataset read-only)\n* one name, one thing \n** different things should have different names\n** don't keep multiple copies of the same thing -- they will eventually become different beasts\n* don't do silent updates or changes -- consider the release number as a part of file name (eg. ''jmsr03.dat'')\n* let users know what's new and what's been changed -- provide a user documentation about each release\n** what's been done: input files, final files\n** variable description\n** data alerts (including discussion about missing values)\n** in(ex)cluded variables and/or observations\n* clarify responsibilities! \n** it helps to distinguish the ''master'' dataset and ''analysis'' datasets\n*** data manager maintains and updates the master dataset and release it as read-only\n*** each analyst can create their own analysis datasets starting from a master dataset\n*** structure directories accordingly. An example:\n{{{\nproject\n - master\n --- r1\n --- r2\n --- r3\n --- r4\n - Changarilla\n --- step01\n --- step02\n --- step03\n --- step04\n - DingDong\n --- freqs\n --- crosstabs\n --- models\n --- graphs\n}}}\n* document, document, document. Here are all the fields you can fill up about single dataset in the data documentation initiative ([[ddi|http://www.icpsr.umich.edu/DDI/index.html]])'s codebook. \n** [[document description|http://webapp.icpsr.umich.edu/cocoon/DDI-LIBRARY/Version2-1.xsd?section=1]]\n** [[study description|http://webapp.icpsr.umich.edu/cocoon/DDI-LIBRARY/Version2-1.xsd?section=2]]\n** [[file description|http://webapp.icpsr.umich.edu/cocoon/DDI-LIBRARY/Version2-1.xsd?section=3]]\n** [[variable description|http://webapp.icpsr.umich.edu/cocoon/DDI-LIBRARY/Version2-1.xsd?section=4]]\n** [[other material|http://webapp.icpsr.umich.edu/cocoon/DDI-LIBRARY/Version2-1.xsd?section=5]]\n* Example [[study description|13646.xml.html]] and [[variable description|13646-0001-Codebook.pdf]] sections\n* at minimum: [[ddi lite|http://www.icpsr.umich.edu/DDI/users/dtd/ddi-lite.html]]\n
... by [[Changarilla|http://changchung.com/changarilla]]
[[Data Management Tips and Tricks]]
http://changchung.com/changarilla/dm.html
[[MPTWStyle]]\n\n/* additional customization \n.selectedTiddler, .unselectedTiddler{\n background-color: #ffffff;\n font-size: 16pt;\n font-family: Century;\n} */
if (!config.plugins) config.plugins = [];\n\nconfig.plugins.TagglyTagging = {\n\n // edit this to your preference. name|date-asc|desc-bullets|commas\n defaultOptions: "name-asc-bullets", \n\n formats: {\n bullets: "*[[%0]]\sn",\n commas: "[[%0]], "\n },\n\n tiddlerFields: {\n name: "title",\n date: "modified"\n }\n\n};\n\nfunction TagglyOptions(optionsString) {\n var opts = optionsString.split("-");\n this.sortField = opts[0];\n this.sortOrder = opts[1];\n this.listFormat = opts[2];\n return this;\n}\n\nTagglyOptions.prototype.toggleListFormat = function() {\n return (this.listFormat == "bullets")?"commas":"bullets";\n}\n\nTagglyOptions.prototype.optionsString = function() {\n return [this.sortField,this.sortOrder,this.listFormat].join("-");\n}\n\nTagglyOptions.prototype.toggleSortOrder = function() {\n return (this.sortOrder == "asc")?"desc":"asc";\n}\n\nTagglyOptions.prototype.formatString = function() {\n return config.plugins.TagglyTagging.formats[this.listFormat];\n}\n\nTagglyOptions.prototype.tiddlerField = function() {\n return config.plugins.TagglyTagging.tiddlerFields[this.sortField];\n}\n\n\nTagglyOptions.prototype.buttonLabels = function() {\n var upArrow = "↑";\n var downArrow = "↓";\n var result = { name: "name", date: "date", format: this.toggleListFormat() };\n // asc means down the page hence arrows are reverse what you might first expect\n if (this.sortField == "name")\n result.name += (this.sortOrder == "desc")?upArrow:downArrow;\n else if (this.sortField == "date")\n result.date += (this.sortOrder == "desc")?upArrow:downArrow; \n return result;\n}\n\n// override function in prototype to allow asc or desc sorting\nstore.reverseLookup_mptw_ascdesc = store.reverseLookup;\nstore.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField,sortAscDesc) {\n var results = this.reverseLookup_mptw_ascdesc(lookupField,lookupValue,lookupMatch,sortField);\n if (sortAscDesc && sortAscDesc == "desc")\n results.reverse();\n return results;\n}\n\n// This is a short function I will just replace it rather than try to hijack. hence may break in future TWs\nstore.getTaggedTiddlers = function(tag,sortField,ascdesc) {\n return this.reverseLookup("tags",tag,true,sortField,ascdesc);\n}\n\nsetStylesheet(\n".tiny {color:#bbb; font-size:80%;padding:0px;margin:0px;margin-right:0.7em;}\sn"+\n"a.tiny {color:#999!important; padding:2px; }\sn"+\n"a.tiny:hover {background:#ddd!important; }\sn"+\n".hideTaggedControls {display:none;}\sn"+\n".showTaggedControls { }\sn"+\n"","taggedControls");\n\nfunction getTaggedTiddlersText(title,options) {\n var tags = store.getTaggedTiddlers(title,options.tiddlerField(),options.sortOrder)\n var str=""; \n for (i=0; i<tags.length; i++)\n str += options.formatString().format([tags[i].title]);\n return str;\n}\n\nfunction getTagglyOptionsString(theTiddler) {\n var element = document.getElementById("taggedOptions"+theTiddler);\n if (element)\n return element.firstChild.nodeValue;\n else \n return null;\n}\nfunction handleOptionClickAndRefresh(theTiddler,thingClicked) {\n\n // get the optionsString out of the taggedOptions invisible span\n var options = new TagglyOptions(getTagglyOptionsString(theTiddler));\n \n if (thingClicked == "name" && options.sortField == "name") \n options.sortOrder = options.toggleSortOrder();\n else if (thingClicked == "date" && options.sortField == "date") \n options.sortOrder = options.toggleSortOrder();\n else if (thingClicked == "date" && options.sortField == "name") \n options.sortField = "date";\n else if (thingClicked == "name" && options.sortField == "date") \n options.sortField = "name";\n else if (thingClicked == "format")\n options.listFormat = options.toggleListFormat();\n\n refreshTaggedList(theTiddler,options,true);\n}\n\nfunction onClickOptName(e) {\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n var theTiddler = findContainingTiddler(theTarget).id.substr(7);\n var state = handleOptionClickAndRefresh(theTiddler,"name");\n return false;\n}\n\nfunction onClickOptDate(e) {\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n var theTiddler = findContainingTiddler(theTarget).id.substr(7);\n var state = handleOptionClickAndRefresh(theTiddler,"date");\n return false;\n}\n\nfunction onClickOptFormat(e) {\n if (!e) var e = window.event;\n var theTarget = resolveTarget(e);\n var theTiddler = findContainingTiddler(theTarget).id.substr(7);\n var state = handleOptionClickAndRefresh(theTiddler,"format");\n return false;\n}\n\n\nconfig.macros.taggedSortControls = {};\nconfig.macros.taggedSortControls.handler = function(place,macroName,params) {\n var opts = new TagglyOptions(params[0]);\n var labels = opts.buttonLabels();\n var b1 = createTiddlyButton(place,labels.name,"Click to sort",onClickOptName,"tiny");\n var b2 = createTiddlyButton(place,labels.date,"Click sort",onClickOptDate,"tiny");\n var b3 = createTiddlyButton(place,labels.format,"Click to change format",onClickOptFormat,"tiny");\n}\n\nfunction onMouseOverTaggedContainer(e) {\n if (!e) var e = window.event;\n var tiddler = findContainingTiddler(resolveTarget(e)).id.substr(7);\n var foo = document.getElementById("taggedControls"+tiddler);\n if (foo) {\n foo.className = "showTaggedControls"; \n }\n\n}\n\nfunction onMouseOutTaggedContainer(e) {\n if (!e) var e = window.event;\n var tiddler = findContainingTiddler(resolveTarget(e)).id.substr(7);\n var foo = document.getElementById("taggedControls"+tiddler);\n if (foo)\n foo.className = "hideTaggedControls";\n}\n\n// use this to (re)build the tagged list for a tiddler\nfunction refreshTaggedList(title,options,donthide) {\n\n if (!options) {\n // must be refreshing already on screen tiddler\n // so read existing options\n // not changing any of them\n var optStr = getTagglyOptionsString(title);\n if (optStr) \n options = new TagglyOptions(optStr);\n }\n if (!options) {\n // must be creating for the first time\n // so read default options\n options = new TagglyOptions(config.plugins.TagglyTagging.defaultOptions);\n }\n\n if (!donthide) donthide = false; // normally hide waiting for mouseover\n var theViewer = document.getElementById("viewer"+title);\n if (theViewer) {\n\n var theTagged = document.getElementById("tagged"+title);\n if (theTagged)\n theTagged.parentNode.removeChild(theTagged);\n\n var taggedText = getTaggedTiddlersText(title,options);\n\n if (taggedText != "") {\n var newTaggedList = createTiddlyElement(theViewer,"div","tagged" + title,"tagged",null); \n createTiddlyElement(newTaggedList,"span",null,"tiny","Tagged as "+title+":"); \n\n // will put the options string in this hidden span so we can read it later\n var newTaggedOptions = createTiddlyElement(newTaggedList,\n "span","taggedOptions" + title, "hideTaggedControls",options.optionsString()); \n\n var newTaggedControls = createTiddlyElement(newTaggedList,\n "span","taggedControls" + title, donthide?"showTaggedControls":"hideTaggedControls",null); \n\n wikify('<<taggedSortControls '+options.optionsString()+'>>', newTaggedControls); \n\n if (options.listFormat == "commas")\n taggedText = taggedText.replace(/^/,"\sn").replace(/, $/,"\sn");\n\n wikify(taggedText, newTaggedList); \n\n newTaggedList.onmouseover = onMouseOverTaggedContainer;\n newTaggedList.onmouseout = onMouseOutTaggedContainer;\n }\n }\n}\n\n// I want to refresh the tagged list in other visible tiddlers\n// this is to refresh if we remove a tiddler\nwindow.deleteTiddler_orig_mptw_tagglytagging = window.deleteTiddler;\nwindow.deleteTiddler = function(title) {\n var oldtags = [];\n var tiddler = store.tiddlers[title];\n if (tiddler) {\n var oldtags = tiddler.tags;\n }\n\n deleteTiddler_orig_mptw_tagglytagging(title);\n\n for (i=0; i<oldtags.length; i++) {\n refreshTaggedList(oldtags[i]);\n }\n}\n\n// this is if we edit a tiddler\n// refresh tags on screen\nwindow.saveTiddler_orig_mptw_tagglytagging = window.saveTiddler;\nwindow.saveTiddler = function(title) {\n\n var newTitle = document.getElementById("editorTitle"+title).value;\n\n var oldtags = [];\n var tiddler = store.tiddlers[title];\n if (tiddler) {\n var oldtags = tiddler.tags;\n }\n \n saveTiddler_orig_mptw_tagglytagging(title);\n\n var newtags = store.tiddlers[newTitle].tags;\n\n for (i=0; i<newtags.length; i++) {\n refreshTaggedList(newtags[i]);\n }\n\n // will do lots twice. should do a unique on oldtags and newtags\n // probably its fast enough that we don't care\n\n for (i=0; i<oldtags.length; i++) {\n refreshTaggedList(oldtags[i]);\n }\n\n}\n\n//==========================================================\n\nwindow.createTiddlerViewer_orig_mptw_tagging = window.createTiddlerViewer;\nwindow.createTiddlerViewer = function(title,highlightText,highlightCaseSensitive) {\n createTiddlerViewer_orig_mptw_tagging(title,highlightText,highlightCaseSensitive);\n refreshTaggedList(title);\n}\n\n\n//==========================================================\n// only change in this is to put the footer above the title... \n// I know that's a bit strange but it's the easiest way to move the tag buttons\n\nwindow.createTiddlerSkeleton_orig_mptw_tagging = window.createTiddlerSkeleton;\nwindow.createTiddlerSkeleton = function(place,before,title)\n{\n var theTiddler = createTiddlerSkeleton_orig_mptw_tagging(place,before,title);\n theFooter = document.getElementById("footer"+title);\n theTitle = document.getElementById("title"+title);\n // want to put the footer up above the title\n theTiddler.childNodes[0].insertBefore(theFooter,theTitle);\n return(theTiddler);\n}\n\n\n//==========================================================\n// I want a TiddlyLink in place of a TagButton\n\nwindow.createTagButton = function(place,tag,excludeTiddler) {\n return createTiddlyLink(place,tag,tag);\n}\n\n//==========================================================\n// this is to make the Tags tab work the same. TiddlyLink instead of Tag button\n\nconfig.macros.allTags.handler = function(place,macroName,params) {\n var tags = store.getTags();\n var theDateList = createTiddlyElement(place,"ul",null,null,null);\n if(tags.length == 0) {\n createTiddlyElement(theDateList,"li",null,"listTitle",this.noTags);\n }\n\n // bad hack so the shorten tab links plugin shortens these a little shorter :)\n var adjustShorten = 2;\n if (config.mptw_shortnames) config.mptw_shortnames.trimAt -= adjustShorten;\n\n for (t=0; t<tags.length; t++) {\n var theListItem=createTiddlyElement(theDateList,"li",null,"listLink",null);\n // not sure why the following doesn't show the count\n var theTag = createTiddlyLink(theListItem,tags[t][0],tags[t][0] + "(" + tags[t][1] + ")");\n // but this puts it in anyway (thanks Clint for this fix).\n theTag.appendChild(document.createTextNode(" ("+tags[t][1]+")")); \n theTag.setAttribute("tag",tags[t][0]);\n }\n\n // other part of bad hack \n if (config.mptw_shortnames) config.mptw_shortnames.trimAt += adjustShorten;\n}\n\n\nconfig.views.wikified.tag.labelNoTags = "";\nconfig.views.wikified.tag.labelTags = "";\n\nsetStylesheet(\n".tagged {background:#f8f8f8;margin-top:0.5em;border: solid #f0f0f0 3px; margin-bottom:0px;padding-bottom:0.5em;padding-left:0.5em;}\sn"+\n".tagged ul {padding-top:0px;margin-top:0px;margin-bottom:2px;list-style-type:square;margin-left:1.2em;padding-left:0;}\sn"+\n".footer a.tiddlyLink { padding-top:0px;margin-right:2em;}\sn"+\n".footer {margin-top:0px;padding-top:0px;}\sn"+\n"",'tagglyTaggingStyles');
window.createTiddlerEditor_mptw_tagstop = window.createTiddlerEditor;\nwindow.createTiddlerEditor = function(title) {\n\n createTiddlerEditor_mptw_tagstop(title);\n\n var theEditor = document.getElementById("editorWrapper"+title);\n var theTitleBox = document.getElementById("editorTitle"+title);\n var theTagsBox = document.getElementById("editorTags"+title);\n var theBodyBox = document.getElementById("editorBody"+title);\n var tagPrompt = document.getElementById("editorFooter"+title);\n\n // so we can style them if we like\n theTitleBox.className += " titleBox";\n theTagsBox.className += " tagsBox";\n\n // put tags box above body\n theEditor.insertBefore(theTagsBox,theBodyBox);\n\n // put "Type tags..." message above body too\n theEditor.insertBefore(theEditor.childNodes[3],theBodyBox);\n\n // add some labels\n var titleLabel = createTiddlyElement(theEditor,"span",null,"titleLabel","Title:");\n var tagsLabel = createTiddlyElement(theEditor,"span",null,"tagsLabel","Tags:");\n var contentLabel = createTiddlyElement(theEditor,"span",null,"contentLabel","Content:");\n\n // put them in the right place\n theEditor.insertBefore(tagsLabel,theTagsBox);\n theEditor.insertBefore(titleLabel,theTitleBox);\n theEditor.insertBefore(contentLabel,theBodyBox);\n\n}
Little tutorial on how to manage the template item stor's. First written on 2004-02-19.\n\nSee the content of the default item stor, sasuser.templat.\n{{{\nproc template;\n list;\nrun;\n}}}\n\nPrepare for updating (or creating if not exists already) the stor called myTmp in the work library.\n{{{\nods path work.myTmp(update)\n sasuser.templat(read)\n sashelp.tmplmst(read)\n;\n}}}\n\nCopy styles.default(in sasuser.templat) to myDefault (in work.myTemp). \n{{{\nproc template;\n edit styles.default as myDefault;\n end; /* <-- you need this */\nrun;\n}}}\n\nSee if it is in there:\n{{{\nproc template;\n list myDefault/store=work.myTmp;\nrun;\n/* on log\nListing of: WORK.MYTMP\nPath Filter is: myDefault\nSort by: PATH/ASCENDING\n\nObs Path Type\n---------------------------\n 1 myDefault Style\n*/\n}}}\n\nNow done. Delete myDefault from work.myTemp.\n{{{\nproc template;\n path work.myTmp(update);\n delete myDefault;\nrun;\n}}}\n\nDelete the item store, work.myTmp itself. First you restore the default ods path, otherwise deleting or the item stor would not work.\n{{{\nods path sasuser.templat(update) \n sashelp.tmplmst(read) \n; \nproc datasets lib=work;\n delete myTmp / mt=itemstor;\nrun;\nquit;\n}}}
is created by Jeremy Ruston. Visit [[www.tiddlywiki.com|http://www.tiddlywiki.com]]. Changarilla is an instance of TiddlyWiki <<version>>.\n
!General\n* make it short but not-too short (e.g. {{{pop1990}}} vs {{{USMidCalendarYear1990TotalPopulation}}})\n* if abbreviated, then try to make it "sayable"; if not, then spell correctly (e.g. C language's {{{creat()}}} [[system call|http://www.scit.wlv.ac.uk/~jphb/spos/notes/calls/creat.html]])\n* consider pre- or post-fix system (e.g. original vs. derived vars)\n* if multi-word name, then be consistent (e.g. {{{camelCasing}}}, {{{using_underscore}}}, ...)\n\n!Stata Specific\n* case sensitive(e.g. {{{var}}}, {{{Var}}}, {{{VAR}}} are all different)\n* names in Stata may be abbreviated (e.g. {{{var}}} and {{{va}}} can refer to the same variable, {{{variable}}})\n* wild characters\n** {{{*}}} : "zero or more characters go here" (e.g. {{{sta*}}}, {{{*rate}}})\n** {{{~}}} : "zero or more characters go here" and "//only one variable matches this specification//" ({{{var}}} is the same as {{{var~}}})\n** consider disabling var name abbreviation ({{{set varabbrev {on | off} }}})\n
\n// //''Code section:''\n// //Webview settings (edit the following with true (enable) or false (disable) according to how the page should look from the web)\nvar wvShowNewTiddler = false; // //''affects all "new tidder" macro links''\nvar wvShowNewJournal = false; // //''affects all "new journal" macro links''\nvar wvDblClickToEdit = false; // //''enables/disables the "double-click to edit a tiddler" feature''\nvar wvShowClose = true; // //''show/hide toolbar close buttons''\nvar wvShowEdit = false; // //''show/hide toolbar edit buttons''\nvar wvShowPermalink = false; // //''show/hide toolbar permalink buttons''\nvar wvShowReferences = false; // //''show/hide toolbar references buttons''\nvar wvShowTags = false; // //''show/hide tiddler tag footers''\nvar wvShowTabs = true; // //''show/hide sidebar tabs entirely (you can also customize them below)''\nvar wvShowCloseOthers = true; // //" show/hide close others button" -- from CloseOthersButton macro\n\n// //Alternate versions of SideBar, Options, AdvancedOptions, SideBarTabs, and MoreTab\nconfig.shadowTiddlers.wvSideBarOptions = "<<search>><<closeAll>><<permaview>><<newTiddler>><<slider chkSliderOptionsPanel OptionsPanel options 'Change TiddlyWiki advanced options'>>";\n\nconfig.shadowTiddlers.wvOptionsPanel = "These InterfaceOptions for customising TiddlyWiki are saved in your browser\sn<<option chkRegExpSearch>> RegExpSearch\sn<<option chkCaseSensitiveSearch>> CaseSensitiveSearch\sn<<option chkAnimate>> EnableAnimations\sn\sn";\n\n\nconfig.shadowTiddlers.wvSideBarTabs = "<<tabs txtMainTab Recent Timeline TabTimeline Index 'All tiddlers' TabMoreAll>>";\n\nconfig.shadowTiddlers.wvTabMore = "<<tabs txtMoreTab Tags 'All tags' TabTags Missing 'Missing tiddlers' TabMoreMissing Orphans 'Orphaned tiddlers' TabMoreOrphans>>";\n\n\n// //''Actual code section (no need to edit below this line for most users)''\n// //------------------------------------------------------------------------------\nversion.extensions.webview = {major: 0, minor: 1, revision: 1, date: new Date(2005,8,10)};\n// Identify special tiddlers to intercept\nvar wvShadowTiddlers = ["SideBarOptions","OptionsPanel","AdvancedOptions","SideBarTabs","TabMore"];\n\n// Determine if the page is being loaded locally or from the web\nvar docPath = document.location.toString().substring(0,document.location.toString().indexOf(":"));\nif(docPath == "file")\n var inWebView = false;\nelse\n var inWebView = true;\n\n// Hijack the newTiddler function\nconfig.macros.newTiddler.handler_orig_webView = config.macros.newTiddler.handler;\nconfig.macros.newTiddler.handler = function(place,macroName,params)\n{\n if (!inWebView || wvShowNewTiddler)\n config.macros.newTiddler.handler_orig_webView(place,macroName,params);\n}\n\n// Hijack the newJournal function\nconfig.macros.newJournal.handler_orig_webView = config.macros.newJournal.handler;\nconfig.macros.newJournal.handler = function(place,macroName,params)\n{\n if (!inWebView || wvShowNewJournal)\n config.macros.newJournal.handler_orig_webView(place,macroName,params);\n}\n\n// Replace "double-click to edit" function\nwindow.onDblClickTiddler_orig_webView = window.onDblClickTiddler;\nwindow.onDblClickTiddler = function(e) {\nif(!inWebView || wvDblClickToEdit)\n {\n clearMessage();\n if(document.selection)\n document.selection.empty();\n var tiddler;\n if(this.id.substr(0,7) == "tiddler")\n tiddler = this.id.substr(7);\n if(tiddler)\n displayTiddler(null,tiddler,2,null,null,false,false);\n }\n}\n\n// Hijack the createTiddlerToolbar function\nwindow.createTiddlerToolbar_orig_webView = window.createTiddlerToolbar;\nwindow.createTiddlerToolbar = function(title,isEditor)\n{\n var theToolbar = document.getElementById("toolbar" + title);\n var lingo = config.views;\n if(theToolbar)\n {\n removeChildren(theToolbar);\n insertSpacer(theToolbar);\n if(isEditor)\n {\n // Editor toolbar\n lingo = lingo.editor;\n createTiddlyButton(theToolbar,lingo.toolbarDone.text,lingo.toolbarDone.tooltip,onClickToolbarSave);\n insertSpacer(theToolbar);\n createTiddlyButton(theToolbar,lingo.toolbarCancel.text,lingo.toolbarCancel.tooltip,onClickToolbarUndo);\n insertSpacer(theToolbar);\n createTiddlyButton(theToolbar,lingo.toolbarDelete.text,lingo.toolbarDelete.tooltip,onClickToolbarDelete);\n }\n else\n {\n // Viewer toolbar\n lingo = lingo.wikified;\n if(!inWebView || wvShowClose)\n {\n createTiddlyButton(theToolbar,lingo.toolbarClose.text,lingo.toolbarClose.tooltip,onClickToolbarClose);\n insertSpacer(theToolbar);\n }\n if(!inWebView || wvShowEdit)\n {\n createTiddlyButton(theToolbar,lingo.toolbarEdit.text,lingo.toolbarEdit.tooltip,onClickToolbarEdit);\n insertSpacer(theToolbar);\n }\n if(!inWebView || wvShowPermalink)\n {\n createTiddlyButton(theToolbar,lingo.toolbarPermalink.text,lingo.toolbarPermalink.tooltip,onClickToolbarPermaLink);\n insertSpacer(theToolbar);\n }\n if(!inWebView || wvShowReferences)\n {\n createTiddlyButton(theToolbar,lingo.toolbarReferences.text,lingo.toolbarReferences.tooltip,onClickToolbarReferences);\n }\n }\n insertSpacer(theToolbar);\n }\n}\n\n// Hijack the createTiddlerFooter function\nwindow.createTiddlerFooter_orig_webView = window.createTiddlerFooter;\nwindow.createTiddlerFooter = function(title,isEditor)\n{\n if(!inWebView || wvShowTags)\n createTiddlerFooter_orig_webView(title,isEditor);\n}\n\n// sideBar, options, and tab settings code\n// Hijack the getTiddlerText prototype function\nTiddlyWiki.prototype.getTiddlerText_orig_webView = TiddlyWiki.prototype.getTiddlerText;\nTiddlyWiki.prototype.getTiddlerText = function(title,defaultText)\n{\n if(inWebView && (wvShadowTiddlers.join("~").match(title) == title))\n {\n defaultText = store.getTiddlerText_orig_webView(title,defaultText);\n var tiddlerText = store.getTiddlerText_orig_webView("wv"+title,defaultText);\n }\n else\n var tiddlerText = store.getTiddlerText_orig_webView(title,defaultText);\n return tiddlerText;\n}\n// Reset the getTiddlerText function for the current store\nstore.getTiddlerText = TiddlyWiki.prototype.getTiddlerText;\n// SideBarTabs show/hide code\n// Remove the old refreshTabs function from notifyTiddlers & store notifications\nfor(t=0; t<config.notifyTiddlers.length; t++)\n if(config.notifyTiddlers[t] == window.refreshTabs)\n config.notifyTiddlers.splice(t,1);\n// Hijack the refreshTabs function\nwindow.refreshTabs_orig_webView = window.refreshTabs;\nwindow.refreshTabs = function(hint)\n{\n if(!inWebView || wvShowTabs)\n refreshTabs_orig_webView(hint);\n else\n document.getElementById("sidebarTabs").style.display = "none";\n}\n// Add our new refreshTabs function to the notifyTiddlers list & store notifications\nconfig.notifyTiddlers.push(refreshTabs());\nstore.addNotification(null,refreshTabs);\n
... to [[DM]] Tips and Tricks by [[Changarilla]]!