[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-573148-105":53,"doc-detail-573148-en":126},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":119,"head_meta":121,"extra_data":123,"updated_unix":125},105,"en","stata-cheat-sheet-basic-syntax-data-processing","Stata Cheat Sheet - Basic Syntax & Data Processing","","Stata cheat sheet covering essential data processing workflows: core command syntax, applying commands by variable combinations, conditional filtering, row-specific operations, and using weights. Provides practical routines for exploring data (describe, count, search, isid, duplicates, levelsof) and browsing observations (data editor, listing, sorting, grouping). Includes setup steps for directories, logging, importing data from common sources, and key commands for summarizing, tabulating, collapsing, and generating new variables.",{"@graph":63,"@context":118},[64,80,101],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/stata-cheat-sheet-basic-syntax-data-processing/573148/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/stata-cheat-sheet-basic-syntax-data-processing/573148.png","ImageObject",442,249,{"name":88,"@type":89},"pixelkiddo","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-18","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":76},"InteractionCounter",{"@type":100},"ViewAction",{"@type":102,"mainEntity":103},"FAQPage",[104,110,114],{"name":105,"@type":106,"acceptedAnswer":107},"What is the standard format for Stata commands in this cheat sheet?","Question",{"text":108,"@type":109},"All Stata commands follow the same syntax: optional by varlist1, the command, optional varlist2 or expression, optional if/in/weight/using, then options after a comma.","Answer",{"name":111,"@type":106,"acceptedAnswer":112},"How can you check whether a variable uniquely identifies the data?",{"text":113,"@type":109},"Use isid, for example isid mpg, to verify that the variable uniquely identifies observations.",{"name":115,"@type":106,"acceptedAnswer":116},"How do you create and summarize new variables like binary flags or derived values?",{"text":117,"@type":109},"Use generate to create new variables (e.g., mpgSq = mpg^2, gen byte lowPr = price \u003C 4000), then summarize or tabulate using commands like tabstat, tabulate, and collapse for grouped statistics.","https://schema.org",{"og:url":78,"og:type":120,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":122,"canonical":78},"index,follow",{"doc_id":124,"site_id":56},573148,1792014485,{"code":4,"msg":5,"data":127},{"doc_id":124,"user_id":128,"nickname":88,"user_avatar":129,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":76,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":135,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":73},962090883892,"https://ap-avatar.wpscdn.com/avatar/e00115db34f3e0f11b?x-image-process=image/resize,m_fixed,w_180,h_180&k=1790152879550218658","Data Processing  \nwith Stata Cheat Sheet  \nFor more info, see Stata’s reference manual ([stata.com](stata.com))  \nUseful shortcuts  \n F2  ~~ ~~ keyboard buttons  \ndescribe data  Ctrl  +  8   \nopen the data editor  \n Ctrl  +  9   \nopen a new do-file  Ctrl  +  D   \nhighlight text in do-file,  \nBasic syntax  \nAll Stata commands have the same format (syntax):  \n[by varlist1:]  command  [varlist2] [=exp]  [if exp]  [in range]  [weight]  [using filename]  [,options]   \napply the command across each unique combination of variables in  \nvarlist1  \nfunction: what are column to save output as condition: only  \nyou going to do apply a new variable apply the function  \n to varlists? command to if something is true  \napply to specific rows  \napply weights  \nbysort rep78 : summarize price if foreign == 0 & price \u003C= 9000, detail ~~ ~~  \npull data from a file (if not loaded)  \nspecial options for command  \nIn this example, we want a detailed summary with stats like kurtosis, plus mean and median  \nTo find out more about any command–like what options it takes–type help command  \nExplore data  \nVIEW DATA ORGANIZATION  describe make price  \ndisplay variable type, format, and any value/variable labels  \ncount  \ncount if price > 5000  \nnumber of rows (observations) can be combined with logic  \ndlsoo, hkafosr(yipn string)  \nsearch for variable types,  \nvariable name, or variable label isid mpg  \ncheck if mpg uniquely identifies the data  \nBROWSE OBSERVATIONS WITHIN THE DATA   \n browse  or  Ctrl  +  8  open the data editor  \nMissing values are treated as the largest poasksitiwvheetnhuembr theer.Tovaluexecisluldeess mthisasnin\"g\"values,  \nlist make price if price > 10000 & !missing(price)  clist ... (compact form)  \nlist the make and price for observations with price > $10,000  \ndisplay the 4th observation in price; only works on single values  \ngsort price mpg (ascending) gsort –price –mpg (descending)  \nsort in order, first by price then miles per gallon  \nduplicates report assert price!=.  \nfinds all duplicate values in each variable verify truth of claim  \n levelsof rep78   \ndisplay the unique values for rep78  \nclear then ctrl + d executes it  \ndelete data in memory in the command line  \nAT COMMAND PROMPT   \n PgDn  scroll through previous commands  Tab  autocompletes variable name after typing part cls clear the console (where results are displayed)  \nSet up  \npwd  \nprint current (working) directory  \ncd \"C:\\Program Files\\Stata16\"  \nchange working directory  \ndir  \ndisplay filenames in working directory  \ndir *.dta  \nList all Stata data in working directory underlined parts  \ncapture log close arusee horcapttcuutre –  \nclose the log on any existing do-files or \"cap\"  \nlog using \"myDoFile .txt\", replace  \ncreate a new log file to record your work and results  \nsearch mdesc  \nfind the package mdesc to install  \n ssc install mdesc    \npackages contain extra commands that expand Stata’s toolkit  \ninstall the package mdesc; needs to be done once  \nImport data  \nsysuse auto, clear  \nload system data (auto data)  \nfor many examples, we use the auto dataset.  \n use \"yourStataFile. dta\", clear   \nload a dataset from the current directory  \nfrequently used  \n import excel \"yourSpreadsheet.xlsx\", /* ~~ ~~ choimmghligahnds arted ineyellow  \n*/ sheet(\"Sheet1\") cellrange(A2:H11) firstrow import delimited \"yourFile.csv\", /*  \n*/ rowrange(2:11) colrange(1:8) varnames(2) import sas \"yourSASfi[le.sas7bdat](le.sas7bdat)\", bcat(\"value labels file\") import spss \"yourSPSSfile.sav\" seemorheeolpptiimponsort for  \nwebuse set \"[https://github.com/GeoCenter/StataTraining/raw/master/Day2/Data](https://github.com/GeoCenter/StataTraining/raw/master/Day2/Data)\"  \nwebuse \"wb_indicators_long\"  \nset web-based directory and load data from the web  \ndisplay price[4]  \n\n| \u003Cbr>Basic data operations\u003Cbr>if something is equal |  |  |\n| --- | --- | --- |\n| Arithmetic |  | Logic\u003Cbr>& and\u003Cbr>==\u003Cbr>= assigns a value to a variable == equal \u003C less than\u003Cbr>! or ~ not ! = not \u003C = less than or ","cbCaikOTpCIzAywA","https://ap.wps.com/l/cbCaikOTpCIzAywA","pdf",3733003,6,"English","# Data Processing with Stata Cheat Sheet\n## Useful shortcuts\n## Basic syntax\n## Explore data\n## Browse observations within the data\n## At command prompt and setup\n## Import data\n## Basic data operations\n## Summarize and transform data","[{\"question\":\"What is the standard format for Stata commands in this cheat sheet?\",\"answer\":\"All Stata commands follow the same syntax: optional by varlist1, the command, optional varlist2 or expression, optional if/in/weight/using, then options after a comma.\"},{\"question\":\"How can you check whether a variable uniquely identifies the data?\",\"answer\":\"Use isid, for example isid mpg, to verify that the variable uniquely identifies observations.\"},{\"question\":\"How do you create and summarize new variables like binary flags or derived values?\",\"answer\":\"Use generate to create new variables (e.g., mpgSq = mpg^2, gen byte lowPr = price \\u003c 4000), then summarize or tabulate using commands like tabstat, tabulate, and collapse for grouped statistics.\"}]","Stata Cheat Sheet - Basic Syntax & Data Processing | PDF",1791933214]