我需要将文本中的空格更改为下划线,但只需要单词之间的空格,而不是数字之间的空格,因此,举个例子
"The quick brown fox 99 07 3475"
Run Code Online (Sandbox Code Playgroud)
会成为
"The_quick_brown_fox 99 07 3475"
Run Code Online (Sandbox Code Playgroud)
我尝试在数据步骤中使用它:
mytext = prxchange('s/\w\s\w/_/',-1,mytext);
Run Code Online (Sandbox Code Playgroud)
但结果不是我想要的
"Th_uic_row_ox 99 07 3475"
Run Code Online (Sandbox Code Playgroud)
关于我能做什么的任何想法?
提前致谢.
对于要以“ J”开头的人,我想将整行变成红色。这可能使用proc print吗?
ods html file=odsout style=htmlblue ;
proc print data=sashelp.class noobs label;
var name age;
run;
ods html close;
Run Code Online (Sandbox Code Playgroud) 我试图动态指定哈希表的密钥.下面的示例工作正常,您可以看到我通过key_list变量指定密钥:
data ht;
set sashelp.class;
key_list = 'name';
if _n_ eq 1 then do;
declare hash ht(dataset:"sashelp.class");
ht.defineKey(key_list);
ht.defineDone();
end;
rc = ht.find();
run;
Run Code Online (Sandbox Code Playgroud)
但以下变化:
key_list = 'name,sex';
Run Code Online (Sandbox Code Playgroud)
...产生警告:
ERROR: Undeclared key symbol name,sex for hash object at line 6144 column 9.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
Run Code Online (Sandbox Code Playgroud)
我已经尝试了单/双引号,空格和逗号等的所有组合,以使这个工作没有任何运气.有没有人能够做到这一点?
我正在寻找非宏观解决方案,谢谢.
当数据组合在一起但是出现故障时,是否有一种方法可以通过SAS中的组处理来使用?
data sample;
input x;
datalines;
3
3
1
1
2
2
;
run;
Run Code Online (Sandbox Code Playgroud)
尝试打印出每组的第一个:
data _null_;
set sample;
by x;
if first.x then do;
put _all_;
end;
run;
Run Code Online (Sandbox Code Playgroud)
导致以下错误:
x=3 FIRST.x=1 LAST.x=0 _ERROR_=0 _N_=1
ERROR: BY variables are not properly sorted on data set WORK.SAMPLE.
x=3 FIRST.x=1 LAST.x=0 _ERROR_=1 _N_=2
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 3 observations read from the data set WORK.SAMPLE.
NOTE: DATA statement used (Total process time): …Run Code Online (Sandbox Code Playgroud) 目前,我有一个数据,包括upc代码.UPC代码中的值范围为3位到5位.因此,我想将所有这些upc代码统一为5位数.
例如,upc代码是111.我将此值设为00111.我如何在sas中执行此操作?