我想在同一数据集中有两个不同的字符串。 我试图用“”分隔valeus,但是没有用。想象一下,我不想只在其中写字符串“”。我搜索了很多,但没有发现任何相关信息。 你们能帮我实现我的目标吗?
data ecl.dim_produtos;
input id_produt id_departament id_order id_business id_portfolio initials $4. long_name $40. short_name $30.;
datalines;
1 1 10201 4 1 PZC "Puzzle Crédito" "Puzzle Crédito"
2 1 10202 4 1 PZR "Puzzle Reestruturados" "Reestruturados"
3 2 10207 30 1 DBO "Banca Online" "Banca Online"
4 3 10210 60 1 CLB "Colaboradores" "Colaboradores"
5 1 10203 4 1 PZF "Puzzle Formação" "Code Academy"
6 4 10205 5 1 HIP "Hipoteca Inversa" "Hip. Inversa"
7 5 10206 25 1 EMP "DEMP" "DEMP"
8 6 10208 45 1 NCO "NewCo" "NewCo"
9 6 10211 70 1 LDRC "Lendrock" "Lendrock"
10 4 10209 50 1 OTI "Otima Provision" "Otima"
11 6 10001 1 1 LDC "Lendico" "Lendico"
12 6 10007 1 1 MIBL "Market Invoice BL - EUR" "Market Invoice BL"
13 6 10003 1 1 CRS "CreditShelf" "CreditShelf"
14 6 10005 1 1 FUN "Funding Circle" "Funding Circle"
15 6 10002 1 1 RAI "Raize" "Raize"
16 4 10204 5 1 FLX "Flex" "Flex"
17 6 10101 2 1 AUX "Auxmoney" "Auxmoney"
18 6 10009 2 1 UPG "Upgrade - EUR" "Upgrade"
19 6 10104 2 1 PRO "Prodigy Finance" "Prodigy"
20 6 10102 2 1 FEL "Fellow Finance" "Fellow"
21 6 10008 1 1 ASZ "Assetz - EUR" "Assetz"
22 6 10010 2 1 LDB "Lendable - EUR" "Lendable"
23 6 10004 1 1 LIN "Linked Finance" "Linked"
24 6 10103 2 1 LDR "Lendrock" "Lendrock"
25 6 10105 3 1 EDX "Edebex" "Edebex"
26 6 10006 1 1 CAM "Camomille - FC" "Camomille"
27 6 10106 3 1 MIN "Market Invoice - EUR" "Market Invoice"
90 0 99991 102 2 DIV "Dívida Pública - EUR" "Dívida Pública"
91 6 99992 103 2 CRP "Obrigações Corporate - EUR" "Obrigações Corporate"
92 0 99990 101 3 SDA "Disp. Aplicações OIC - EUR" "Disp. Aplicações OIC"
9999 0 999999 999 99 TOT "Total Patrimonial - EUR" "Total Patrimonial"
;
run;
答案 0 :(得分:0)
如果要在INPUT语句中包含信息规范,请首先使用pip install pyparsing
修饰符,以避免在列表输入模式和格式化输入模式之间切换。
如果可以确保两个值之间至少有两个空格(并且值本身内部没有相邻的空格),则可以使用:
修饰符。
&
或者保留引号,并确保每个值之间只有一个空格(并且不要缩进数据行!)并添加DSD选项。
data test;
input id_produt id_departament id_order id_business id_portfolio
initials &:$4. long_name &:$40. short_name &:$30.
;
datalines;
1 1 10201 4 1 PZC Puzzle Crédito Puzzle Crédito
2 1 10202 4 1 PZR Puzzle Reestruturados Reestruturados
;
或者使用带有或不带有DSD选项的其他定界符。
data test;
infile datalines dsd dlm=' ' truncover ;
input id_produt id_departament id_order id_business id_portfolio
initials :$4. long_name :$40. short_name :$30.
;
datalines;
1 1 10201 4 1 PZC "Puzzle Crédito" "Puzzle Crédito"
2 1 10202 4 1 PZR "Puzzle Reestruturados" "Reestruturados"
;
答案 1 :(得分:0)
最可靠的方法是:
INPUT
或length
语句定义attrib
语句的变量。INFILE
选项来指定INPUT
解析数据行的方式$
语句中取出INPUT
示例(按原样保留数据行):
length
id_produt id_departament id_order id_business id_portfolio 8
initials $4
long_name $40
short_name $30
;
infile cards dsd dlm=" ";
对于需要用双引号引起来的数据行,您将必须修改数据行以用两个或多个空格分隔值,并使用&
参数作为列表样式{{ 1}}语句。
您还可以使用INPUT
字符分隔数据行中的值,并使用tab
。使用SAS编辑器查看和输入标签可能会有些麻烦。