SAS函数学习笔记——字符操作

更新时间:2024-02-13 21:58:01 阅读: 评论:0

2024年2月13日发(作者:红青年)

SAS函数学习笔记——字符操作

STRING = "ABC 123 ?xyz_n_"; Function Returns ———————————————————————————————— ANYALNUM(STRING) 1 (position of "A") ANYALNUM("??%%") 0 (no alpha-numeric characters) ANYALNUM(STRING,5) 5 (position of "1") ANYALNUM(STRING,-4) 3 (position of "C") ANYALNUM(STRING,6) 6 (position of "2") NOTALNUM(STRING) 4 (position of the 1st blank) NOTALNUM("Testing123") 0 (all alpha-numeric values) NOTALNUM("??%%") 1 (position of the "?") NOTALNUM(STRING,5) 8 (position of the 2nd blank) NOTALNUM(STRING,-6) 4 (position of the 1st blank) NOTALNUM(STRING,8) 9 (position of the "?") ————————————————————————————————— ANYALPHA(STRING) 1 (position of "A") ANYALPHA("??%%") 0 (no alpha characters) ANYALPHA(STRING,5) 10 (position of "x") ANYALPHA(STRING,-4) 3 (position of "C") ANYALPHA(STRING,6) 10 (position of "x") NOTALPHA(STRING) 4 (position of 1st blank) NOTALPHA("ABCabc") 0 (all alpha characters) NOTALPHA("??%%") 1 (position of first "?") NOTALPHA(STRING,5) 5 (position of "1") NOTALPHA(STRING,-10) 9 (start at position 10 and arch left, position of "?") NOTALPHA(STRING,2) 4 (position of 1st blank) ————————————————————————————————— ANYDIGIT(STRING) 5 (position of "1") ANYDIGIT("??%%") 0 (no digits) ANYDIGIT(STRING,5) 5 (position of "1") ANYDIGIT(STRING,-4) 0 (no digits from position 4 to 1) ANYDIGIT(STRING,6) 6 (position of "2") NOTDIGIT(STRING) 1 (position of "A") NOTDIGIT("123456") 0 (all digits) NOTDIGIT("??%%") 1 (position of "?") NOTDIGIT(STRING,5) 8 (position of 2nd blank) NOTDIGIT(STRING,-6) 4 (position of 1st blank) NOTDIGIT(STRING,6) 8 (position of 2nd blank) ————————————————————————————————— ANYSPACE(STRING) 4 (position of the first blank) ANYSPACE("??%%") 0 (no spaces) ANYSPACE(STRING,5) 8 (position of the cond blank) ANYSPACE(STRING,-4) 4 (position of the first blank) ANYSPACE(STRING,6) 8 (position of the cond blank) ————————————————————————————————— STRING = "A!C 123 ?xyz_n_"; Function Returns ————————————————————————————————— ANYPUNCT(STRING) 2 (position of "!") ANYPUNCT("?? %%") 1 (position of "?") ANYPUNCT(STRING,5) 9 (position of "?") ANYPUNCT(STRING,-4) 2 (starts at position 4 and goes left, positionof "!" ) ANYPUNCT(STRING,-3) 2 (starts at "C" and goes left, position of "!")

A = "Bilbo" (no blanks) B = " Frodo" (leading blanks) C = "Hobbit " (trailing blanks) D = " Gandalf " (leading and trailing blanks) C1-C5是五个字符变量,分别为'A'、'B'、'C'、'D'和'E'。 Function Returns ———————————————————————————————— CALL CATS(RESULT, A, B) "BilboFrodo" CALL CATS(RESULT, B, C, D) "FrodoHobbitGandalf" CALL CATS(RESULT, "Hello", D) "HelloGandalf" CALL CATT(RESULT, A, B) "Bilbo Frodo" CALL CATT(RESULT, B, C, D) " FrodoHobbit Gandalf" CALL CATT(RESULT, "Hello", D) "Hello Gandalf" CALL CATX(" ", RESULT, A, B) "Bilbo Frodo" CALL CATX(",", RESULT, B, C, D) "Frodo,Hobbit,Gandalf" CALL CATX(":", RESULT, "Hello", D) "Hello:Gandalf" CALL CATX(", ", RESULT, "Hello", D) "Hello, Gandalf" CALL CATX("***", RESULT, A, B) "Bilbo***Frodo" CAT(A, B) "Bilbo Frodo" CAT(B, C, D) " FrodoHobbit Gandalf " CAT("Hello", D) "Hello Gandalf " CAT(OF C1-C5) "ABCDE" CATS(A, B) "BilboFrodo" CATS(B, C, D) "FrodoHobbitGandalf" CATS("Hello", D) "HelloGandalf" CATS(OF C1-C5) "ABCDE" CATT(A, B) "Bilbo Frodo" CATT(B, C, D) " FrodoHobbit Gandalf" CATT("Hello", D) "Hello Gandalf" CATT(OF C1-C5) "ABCDE" CATX(" ", A, B) "Bilbo Frodo" CATX(":"B, C, D) "Frodo:Hobbit:Gandalf" CATX("***", "Hello", D) "Hello***Gandalf" CATX("," ,OF C1-C5) "A,B,C,D,E" ———————————————————————————————— RESULT = " 123 "(leading and trailing blanks) Function Returns ————————————————————————————————— CALL CATS(RESULT, A, B) "123BilboFrodo" CALL CATS(RESULT, B, C, D) "123FrodoHobbitGandalf" CALL CATS(RESULT, "Hello", D) "123HelloGandalf" CALL CATT(RESULT, A, B) " 123Bilbo Frodo" CALL CATT(RESULT, B, C, D) " 123 FrodoHobbit Gandalf" CALL CATT(RESULT, "Hello", D) " 123Hello Gandalf" CALL CATX(" ", RESULT, A, B) "123 Bilbo Frodo" CALL CATX(",", RESULT, B, C, D) "123,Frodo,Hobbit,Gandalf" CALL CATX(":", RESULT, "Hello", D) "123:Hello:Gandalf" CALL CATX(", ", RESULT, "Hello", D) "123, Hello, Gandalf" CALL CATX("***", RESULT, A, B) "123***Bilbo***Frodo"6、从字符串中删除空格的函数

NUM1 = 5, NUM2 = ., CHAR1 = "ABC", and CHAR2 = " " Function Returns ——————————————————————————— MISSING(NUM1) 0 MISSING(NUM2) 1 MISSING(CHAR1) 0 MISSING(CHAR2) 1 ——————————————————————————— STRING1 = "A" and STRING2 = "XYZ" Function Returns —————————————————————————— RANK(STRING1) 65 RANK(STRING2) 88 RANK("X") 88 RANK("a") 97 —————————————————————————— STRING = "ABC" Function Returns —————————————————————————————— REPEAT(STRING,1) "ABCABC" REPEAT("HELLO ",3) "HELLO HELLO HELLO HELLO" REPEAT("*",5) "******" —————————————————————————————— STRING1 = "ABCDE" and STRING2 = "XYZ " Function Returns —————————————————————————————— REVERSE(STRING1) "EDCBA" REVERSE(STRING2) " ZYX" REVERSE("1234") "4321"

SAS函数学习笔记——字符操作

本文发布于:2024-02-13 21:58:01,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/zhishi/a/1707832681141215.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:SAS函数学习笔记——字符操作.doc

本文 PDF 下载地址:SAS函数学习笔记——字符操作.pdf

下一篇:返回列表
标签:笔记   字符   函数   学习   空格
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 实用文体写作网旗下知识大全大全栏目是一个全百科类宝库! 优秀范文|法律文书|专利查询|