I try to generate standard graphs with every numeric variable in my dataset and create a nice looking data report with dyndoc. I am not figuring out if creating graphs in a loop with dyndoc let me insert these graphs (Stata 15). My code looks currently like:
Code:
<<dd_version: 1>> # Distribution of Variables in data set <<dd_do: quietly>> clear set more off global p_data "N:\Ablagen\D01700-IAB-Projekte\D01700-BPSE\2019_Datensaetze\" global p_graphs "N:\Ablagen\D01700-KEM\Survey-Einheit\Projekte_spezifisch\FBD1_Projekte_Betriebe_Beschaeftigung\201910_Betriebspanel_Datencheck\graphs\" use myfile_ext.dta foreach x of varlist * { confirm numeric variable `x' if !_rc { capture drop unique egen unique = group(`x') quietly: summarize unique if `r(max)' < 10{ di "Variable: `x'" graph bar , over(`x') blabel(bar, format(%4.1f)) intensity(25) /// ytitle("in Prozent (`x')", size(small)) graph save "$p_graphs\g_`x'.gph", replace * NOT WORKING: * <<dd_graph: sav("g_`x'.svg") alt("scatter mpg weight") replace height(400)>> } else{ } } } <</dd_do>>
<<dd_graph: sav("g_`x'.svg") alt("scatter mpg weight") replace height(400)>>
What I have tried so far:
- saving Graphs in loop and using them later - is not working
- Looping the dyndoc.txt file itselve. That works but creates instead of one html several html files and "append" is not working with dyndoc
- use putdocx instaed: that works actually, but putdocx gives me trouble with other output I want to create. I prefer very much dyndoc….
Thankyou very much in advance,
Marieke
0 Response to Creating and displaying graphs in a loop with dyndoc
Post a Comment