1 Star 0 Fork 3

宇豪/eda

forked from 连享会/eda 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
grlabsplit.ado 2.65 KB
一键复制 编辑 原始数据 按行查看 历史
********************************************************************************
* Description of the Program - *
* Utility to split variable labels for multiline titles/axis titles *
* *
* Program Output - *
* char varname[ti1] - First half of graph titles/labels for this variable *
* char varname[ti2] - Second half of graph titles/labels for this variable *
* char varname[title] - A string that can be used for titles in graphs *
* *
* Lines - *
* 78 *
* *
********************************************************************************
*! grlabsplit
*! v 0.0.1
*! 17jul2018
// Drop program from memory if loaded
cap prog drop grlabsplit
// EDA subroutine that writes split graph titles to dataset characteristics
prog def grlabsplit
// Requires a variable list
syntax varlist [, GRLABLength(int 50)]
// Loop over variable list
foreach v in `varlist' {
// Get variable label
loc graphlab : var l `v'
// Remove apostrophes
loc graphlab : subinstr loc graphlab "'" "", all
// Get the length of the x-axis variable lable
loc lablength : length loc graphlab
// Get the number of chunks needed to split the label
loc chunks = ceil(`lablength' / `grlablength')
// Make sure to allocate enough chunks in cases where the label length
// is less than the grlablength parameter
if `lablength' > `grlablength' & `chunks' < 2 {
// Add one to the chunk macro
loc chunks = 2
} // End IF Block for shorter variable labels than split length
// Holder for title string
loc title `""'
// If the variable label is longer than `grlablength' characters split it
forv i = 1/`chunks' {
// Extracts a chunk from the variable label
loc tmplab : piece `i' `grlablength' of `"`: var label `v''"', nobreak
// Stores the label chunk in a characteristic
char `v'[ti_chunk_`i'] "`tmplab'"
// Add chunk to title string
loc title `"`title'"`tmplab'" "'
} // End IF Block for splitting variable labels
// Store the title string in a characteristic
char `v'[title] "`title'"
// Store the length of the original label
char `v'[lablen] `lablength'
} // End Loop over variable list
// End of subroutine for splitting variable labels for titles
end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xyuhao/eda.git
git@gitee.com:xyuhao/eda.git
xyuhao
eda
eda
master

搜索帮助