我在Stata中有一些脚本编写如下:
* 1. count of firms in each bin
grouplabs Inear_dist_km_0_10 Inear_dist_km_10_30 Inear_dist_km_30_60 Inear_dist_km_60_100 Inear_dist_km_100_150 Inear_dist_km_morethan150, groupvar(Inear_dist_km_gr) emptylabel(empty)
graph hbar (count) if Inear_dist_km_gr !=1, over(Inear_dist_km_gr) name(n1)
* 2. count of firms in each bin (bigger bins)
grouplabs Inear_dist_km_0_20_v2 Inear_dist_km_20_40_v2 Inear_dist_km_40_60_v2 Inear_dist_km_morethan60_v2, groupvar(Inear_dist_km_v2_gr) emptylabel(empty)
graph hbar (count) if Inear_dist_km_v2_gr !=1, over(Inear_dist_km_v2_gr) name(n2)
* 3. GGK firm level bins
grouplabs Inear_dist_km_GGK_0_10 Inear_dist_km_GGK_10_50 Inear_dist_km_GGK_morethan50, groupvar(Inear_dist_km_GGK_gr) emptylabel(empty)
graph hbar (count) if Inear_dist_km_GGK_gr !=1, over(Inear_dist_km_GGK_gr) name(n3)
我需要在每行的末尾添加字符;
,但不要在每个脚本之间的空行中添加。我已尝试使用Split into Lines技巧在每行的末尾获得多个游标,但选择中还包括两行之间的空行。这导致
* 1. count of firms in each bin;
grouplabs Inear_dist_km_0_10 Inear_dist_km_10_30 Inear_dist_km_30_60 Inear_dist_km_60_100 Inear_dist_km_100_150 Inear_dist_km_morethan150, groupvar(Inear_dist_km_gr) emptylabel(empty);
graph hbar (count) if Inear_dist_km_gr !=1, over(Inear_dist_km_gr) name(n1);
;
* 2. count of firms in each bin (bigger bins);
grouplabs Inear_dist_km_0_20_v2 Inear_dist_km_20_40_v2 Inear_dist_km_40_60_v2 Inear_dist_km_morethan60_v2, groupvar(Inear_dist_km_v2_gr) emptylabel(empty);
graph hbar (count) if Inear_dist_km_v2_gr !=1, over(Inear_dist_km_v2_gr) name(n2);
;
* 3. GGK firm level bins;
grouplabs Inear_dist_km_GGK_0_10 Inear_dist_km_GGK_10_50 Inear_dist_km_GGK_morethan50, groupvar(Inear_dist_km_GGK_gr) emptylabel(empty);
graph hbar (count) if Inear_dist_km_GGK_gr !=1, over(Inear_dist_km_GGK_gr) name(n3);
如何从选区中排除空行,以便只有包含字符的行在结尾处有;
?感谢您的帮助。
答案 0 :(得分:2)
如果您确定空行是空白且未填充空白字符,请按 ctrl + H 使用正则表达式替换,搜索对于(?<!^)$
并替换为;
。
$
)开头((?<!…)
)之后不要直接找到行尾(^
)。否则请搜索(?<=\S)$
,但请确保您不要使用任何尾随空格或标签。
[^\S\n]+$
找到并删除。第一个正则表达式是:在((?<=…)
)非空白字符后直接找到行尾,包括换行符。
第二个正则表达式是:查找不是(…+
)非空格字符或换行符的字符序列([^…]
) - 即排除空格字符的序列换行 - 然后是行尾。
^\s*$
,