楼主: guo.bailing
9631 4

[问答] %upcase和%Qupcase函数的差别 [推广有奖]

区版主

已卖:275份资源

大师

30%

还不是VIP/贵宾

-

TA的文库  其他...

文库1

文库2

文库3

威望
6
论坛币
1336379 个
通用积分
20289.1888
学术水平
558 点
热心指数
776 点
信用等级
515 点
经验
147031 点
帖子
4111
精华
24
在线时间
10956 小时
注册时间
2009-7-9
最后登录
2025-11-21

初级热心勋章 中级热心勋章 初级信用勋章 初级学术勋章

楼主
guo.bailing 发表于 2011-1-3 11:58:11 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题,下面是帮助文档里面的文件,以前不怎么看帮助文档,不过最近在里面找了一下,发现很全很强大,就是看起来觉得很不适应,估计是英文水平比较菜。请高手们帮忙看看,总结一下这两个函数的差别,谢谢了。
好的英语水平真的很重要啊!

%UPCASE and %QUPCASE Functions
Convert values to uppercase.
Type:Macro function
See also:
%LOWCASE and %QLOWCASE Autocall Macros
%NRBQUOTE Function
%QLOWCASE Autocall Macro
Syntax
Details
Comparison
Examples
Example 1: Capitalizing a Value to be Compared
Example 2: Comparing %UPCASE and %QUPCASE
Syntax
%UPCASE (character string | text expression)
%QUPCASE(character string | text expression)



Details

The %UPCASE and %QUPCASE functions convert lowercase characters in the argument to uppercase. %UPCASE does not mask special characters or mnemonic operators in its result, even when the argument was previously masked by a macro quoting function.
If the argument contains a special character or mnemonic operator, listed below, use %QUPCASE. %QUPCASE masks the following special characters and mnemonic operators in its result:
& % ' " ( ) + - * / < > = ? ^ ~ ; , # blankAND OR NOT EQ NE LE LT GE GT IN
%UPCASE and %QUPCASE are useful in the comparison of values because the macro facility does not automatically convert lowercase characters to uppercase before comparing values.
Comparison


  • %QUPCASE masks the same characters as the %NRBQUOTE function.
  • To convert characters to lowercase, use the %LOWCASE or %QLOWCASE autocall macro.
Examples


Example 1: Capitalizing a Value to be Compared In this example, the macro RUNREPT compares a value input for the macro variable MONTH to the string DEC. If the uppercase value of the response is DEC, then PROC FSVIEW runs on the data set REPORTS.ENDYEAR. Otherwise, PROC FSVIEW runs on the data set with the name of the month in the REPORTS data library.
%macro runrept(month);   %if %upcase(&month)=DEC %then       %str(proc fsview data=reports.endyear; run;);   %else %str(proc fsview data=reports.&month; run;);%mend runrept;
You can invoke the macro in any of these ways to satisfy the %IF condition:
%runrept(DEC)%runrept(Dec)%runrept(dec)

Example 2: Comparing %UPCASE and %QUPCASE These statements show the results produced by %UPCASE and %QUPCASE:
%let a=begin;%let b=%nrstr(&a);%put UPCASE produces: %upcase(&b);%put QUPCASE produces: %qupcase(&b);
When these statements execute, the following is written to the SAS log:
UPCASE produces: beginQUPCASE produces: &A
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:upcase Case CAS pca Capitalizing 函数 upcase

回帖推荐

pobel 发表于2楼  查看完整内容

假设有一字符串,以逗号分隔。 %let string=aaa,bbb,ccc; 如果想检测其第二个词的大写形式是不是BBB: 因为函数中也需要用逗号分隔各个参数,为了让SAS将字符串aaa,bbb,ccc中的两个逗号看作普通字符,而不是参数分隔符,就需要将该字符串中的逗号的参数分隔功能屏蔽掉,这时会需要用到%QUPCASE: %let second=%scan(%qupcase(&string),2,%str(,)); %put %sysfunc(ifc(&second eq BBB, The second word is BBB., The second ...

本帖被以下文库推荐

自助者,天助之!

沙发
pobel 在职认证  发表于 2011-1-4 07:31:04
假设有一字符串,以逗号分隔。
%let string=aaa,bbb,ccc;

如果想检测其第二个词的大写形式是不是BBB:
因为函数中也需要用逗号分隔各个参数,为了让SAS将字符串aaa,bbb,ccc中的两个逗号看作普通字符,而不是参数分隔符,就需要将该字符串中的逗号的参数分隔功能屏蔽掉,这时会需要用到%QUPCASE:
%let second=%scan(%qupcase(&string),2,%str(,));
%put %sysfunc(ifc(&second eq BBB, The second word is BBB., The second word is not BBB.));

这里%qupcase()相当于 %quote(%upcase())
%let second=%scan(%quote(%upcase(&string)),2,%str(,));
%put %sysfunc(ifc(&second eq BBB, The second word is BBB., The second word is not BBB.));
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
guo.bailing + 2 + 2 + 2 非常感谢您的回答!

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

和谐拯救危机

藤椅
冰雨狼 发表于 2013-4-23 22:33:23
二楼举得例子不错。

板凳
alex1206 发表于 2015-8-19 03:55:39
多谢楼主分享!!!

报纸
teqel 发表于 2015-8-19 09:03:29
第二个例子是说,能屏蔽& AND %

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 03:33