SAS, along with groSolar and FLS Energy, has completed its second solar farm on the company’s Cary, NC, headquarters campus.

1. upcase ()

```data _null_;
name1=upcase("Yuewei Liu");
name2="Zhu Qi";
name2=upcase(name2);
blank=upcase("  ");
put name1/name2/blank;
run;

/* 结果 */

YUEWEI LIU
ZHU QI```

2. lowcase()

```data _null_;
name1=lowcase("Yuewei Liu");
name2="Zhu Qi";
name2=lowcase(name2);
blank=lowcase("  ");
put name1/name2/blank;
run;

/* 结果 */

yuewei liu
zhu qi```

3. propcase()

```/* 1. 修改字符串大小写 */
data _null_;
input place \$ 1-40;
name=propcase(place);
put name;
datalines;
INTRODUCTION TO THE SCIENCE OF ASTRONOMY
VIRGIN ISLANDS (U.S.)
SAINT KITTS/NEVIS
WINSTON-SALEM, N.C.
;
run;

/* 结果输出 */
Introduction To The Science Of Astronomy
Virgin Islands (U.S.)
Saint Kitts/Nevis
Winston-Salem, N.C.

/* 2. 和其它函数配合使用 */
data _null_;
x=lowcase('THIS IS A DOG');
y=propcase(x);
z=propcase(lowcase('THIS IS A DOG'));
put x=;
put y=;
put z=;
run;

/* 结果输出 */
x=this is a dog
y=This Is A Dog
z=This Is A Dog

/* 3. 和其它函数配合使用 */
data _null_;
string1='VERY RARE BOOKS';
case1=propcase(string1);
put case1=;
case2=propcase(tranwrd(string1, 'VERY', ' '));
put case2=;
run;

/* 结果输出 */
case1=Very Rare Books
case2=  Rare Books

/* 4. 结合分隔符一起使用 */
options pageno=1 nodate ls=80 ps=64;
data names;
infile datalines dlm='#';
input CommonName : \$20. CapsName : \$20.;
PropcaseName=propcase(capsname, " -'");
datalines;
Delacroix, Eugene# EUGENE DELACROIX
O'Keeffe, Georgia# GEORGIA O'KEEFFE
Rockwell, Norman# NORMAN ROCKWELL
Burne-Jones, Edward# EDWARD BURNE-JONES
;

proc print data=names noobs;
title 'Names of Artists';
run;

/* 结果输出 */
CommonName              CapsName            PropcaseName
Delacroix, Eugene      EUGENE DELACROIX      Eugene Delacroix
O'Keeffe, Georgia      GEORGIA O'KEEFFE      Georgia O'Keeffe
Rockwell, Norman       NORMAN ROCKWELL       Norman Rockwell
Burne-Jones, Edward    EDWARD BURNE-JONES    Edward Burne-Jones```

```data  _null_;
length char char1 char2 \$ 15;
char="this is a test";
char1=propcase(char,"-");
char2=upcase(substr(char,1,1))||substr(char,2);
char3=char;
substr(char3,1,1)=upcase(substr(char3,1,1));
put char1=/char2=/char3=;
run;

char1=This is a test
char2=This is a test
char3=This is a test```

 您可能也喜欢： SAS 中使用 Compress 函数删除或保留字符串中特定字符 SAS 字符串连接方法 SAS 读取含多个分隔符的数据 SAS 中使用 Unamed Pipe 获取文件名 SAS 中使用中文变量名 无觅
Related Posts

Yesterday, I was in the #raganSAS audience as David Pogue told me What's New and What's Next in the world of technology. David is a great presenter, and he really had the audience engaged as he talked about augmented reality, his world according to Twitter, and an iPhone app that comes pretty close to teaching the world to sing in perfect harmony (plus a cheater app that helps the world to sing like T. Pain).

On the world-harmony-for-profit theme, he shared information about web sites such as Kiva.org that facilitate microfinancing around the world. There are other microfinance sites that help people closer to home (for us in the USA), but as Pogue said, only Kiva.org can give you that "rosy glow" when you know you're helping people in developing countries.

Kiva.org opens financial doors for people who might not have another source of funding; but it also presents a platform rich in data for analysis and reporting. The folks at Kiva.org support web services that allow you to build applications that reference the data that they collect. They also offer "data snapshots": downloadable versions of all of the data they have on the loans, loan recipients, and the lenders who participate.

If you could get this data into SAS, what insights could you glean? What cool stats could you produce? What stories could you tell with charts and plots?

So, now we come to your homework assignment...if you choose to accept it. I've already done the grunt work of writing a SAS program that transforms the raw data (from its XML format) into SAS data sets. I've even written a sample step that produces a simple chart based on the current data.

What can you do with this data using SAS? There are two data sets: lenders (over 400,000 records) and loans (over 165,000 records). They contain columns relating to geography (location of lenders and loan recipients), quantity (how many loans, what amounts), categories (loan purpose/industry, gender of recipient), and time (when the loan was granted/funded). You can read about the data on Kiva.org, and then create interesting reports using SAS.

Bonus assignment: can you improve my SAS program that pulls the data into SAS? I promise you: there is lots of room for optimization. (If I held off of this post until I perfected it, it would be ready for World Statistics Day 2011.) My implementation uses the XML libname engine, DATA step, and PROC SQL. It could be more automated (download the zip file with FILENAME URL, extract and process) and more efficient (faster appends, perhaps joining and summarizing for easier analysis). The program encounters a few errors when it runs, probably due to character encoding in the XML data. What would you do differently?

Here's how you can get started:

• Download my SAS program and XML map files from this ZIP file here (small, just about 3K).
• Extract the ZIP file to a new folder that your SAS session can access as the Kiva "root" folder (example: "C:\public\Kiva" or "/u/userid/Kiva").
• Download the data snapshot from Kiva.org (big, about 150MB ZIP file). You need the XML format (not the JSON format).
• Extract the data snapshot files into your Kiva "root" folder.
• Modify my kivaProgram.sas file to set the Kiva data root folder, and set the number of loan XML files and lender XML files (as described in the comments in the program).

(By the way, I wrote this program entirely using SAS Enterprise Guide 4.3. So I know that you can run it from there, or within whatever SAS 9.2 environment you have access to.)

What better way to celebrate World Statistics Day than to compute some statistics for the world? Post your experiences back here in the comments, or use sasCommunity.org to share more details and post the link.

Refresh some basic logical propositions (or statements):

implication:       if       P then       Q (P>Q)

inverse:            if not P then not Q (-P>-Q)

converse:         if       Q then       P (Q>P)

contrapositive: if not Q then not P (-Q>-P)

contradition:    if       P then not Q (P>-Q)

Mathematically or logically speaking, if the implication statement holds, then the contrapositive holds, but the inverse does not hold, i.e., if P then Q, then we can get if not Q then not P, but we can not get if not P then not Q.

That’s all logics needed here and Let’s turn to the ambiguous English in daily life. James R. Munkres of MIT gave an example in Topology (2nd edition, 2000, P.7):

Mr. Jones, if  you get a grade below  70 on  the final, you are going to flunk  this course.

We adapt it in a logical implication form:

Mr. Jones, if P then Q, where

P: you get a grade below  70 on  the final

Q: you are going to flunk  this course

Considering the context, we can also get that the inverse holds: if you get a grade above er or equal to 70, then you are going to pass this course(if not P then not Q ).

Question: when do statistical programming, what types of logics you use?

if score<70 then grade="flunk";  *if P then Q;
else                    grade="pass";  *if not P then not Q;

If you're an administrator of systems that run SAS, you have probably already read up on How to Maintain Happy SAS 9 Users. If not, go read that first. Now, are you looking to squeeze the best performance out of SAS on Microsoft Windows 2008 Server? Be sure to read this latest paper with additional configuration and tuning guidelines. The paper describes how the Windows operating-system file cache can have a big impact on performance, especially under large I/O workloads. There are some tuning steps that you can apply; they are a combination of Microsoft Windows updates, configuration settings, and SAS system options. The paper is the result of collaboration among SAS Technical Support, SAS R&D, and SAS customers, and Microsoft. It contains lots of good advice, plus links to related papers for further details.

Tagged with:

I recently had the pleasure to sit in on one of our customer presentations at the CRM Evolution Conference in New York. Sean Lowe, the Managing Director of Endless Vacation Rentals and Revenue Management for Wyndham Exchange & Rentals, gave a presentation about how his company manages the demand forecasting process for the RCI operating unit.

Sounds like it might be a dry topic, right? Not at all. It turned out to be a fascinating story about how they were able to focus on solving a business problem, and how they turned it into a strategic advantage that drives customer satisfaction.

RCI stands for Resort Condominiums International, which pioneered vacation ownership exchange in 1974 and strives to create flexibility for two key markets - resort developers and vacation owners. Among the vacation owners, at any given time the property owners may also be property seekers, hence the concept of the exchange. RCI is the industry leader, having facilitated 2 million exchange vacations last year – three times more than its nearest competitor. As Sean proceeded to explain why they engage in demand forecasting, the beautiful symmetry of it all became apparent.

Every time a timeshare owner successfully finds another property they want to try, RCI earns a fee. The property seeker is happy when they get the property they want at the time they need it. The property owner is happy when they get the best exchange value they could get for their property at the time of the transaction. And RCI helps ensure a source of future revenue by making both the property owners and property seekers happy. And with an efficient exchange market, it provides an incentive for resort developers to participate in the RCI network as a key benefit to their customers, who buy into the properties to begin with. So all that happens smoothly as a result of accurately forecasting demand and setting prices accordingly.

When you’re able to make multiple stakeholders happy, while helping to drive future revenues and grow your business, that’s a value proposition that translates to success in any business. Sean started out by jokingly assuring us he would not try to talk us into a timeshare in Marbella or Miami, but after hearing his story, I’ll bet he might have had a few takers by the time he finished.

Last month, I gave a talk, XML: the SAS Approach, in CDISC Interchange China 2010(at the Medical School of Fudan University, Shanghai, 2010-09-15). FDA favors CDISC and HL7, the two XML based standards, and SAS programmers in biopharmaceutical industry  need incorporate the XML technology into their toolboxes. Fortunately, you don’t need to be an XML expert then to play XML in your daily work, and, SAS system DOES offer multiple tools and applications to handle XML files, i.e. import and export XML data:

• SAS data steps approach:                        import and export
• SAS XML Libname engine:                         import and export
• SAS ODS XML statement(ODS MARKUP):   export
• PROC CDISC:                                            import and export
• SAS XML Mapper:                                      import
• SAS CDISC Viewer:                           as if  import

The SAS CDISC Viewer and PROC CDISC procedure are some bit toys, and the rest really work. The Perl Regular Expression(PRX) approach is also presented to export and import XML data.

A simple demo. First, use FILE and PUT statements to generate an XML file:

data _null_;
file "export.xml";
put ‘<?xml version="1.0" encoding="windows-1252" ?>’;
put ‘<ROWSET>’;
put ‘<ROW>’;
put ‘<text> Welcome to CDISC Interchange 2010 China </text>’;
put ‘</ROW>’;
put ‘<ROW>’;
put ‘<text> We are in Shanghai! </text>’;
put ‘</ROW>’;
put ‘</ROWSET>’;
run;

Then read the whole XML file to SAS dataset:

data import0 ;
infile "export.xml" dsd missover truncover lrecl = 1024;
input line \$1024.;
if line = ” then delete;
run;

Third step, extract the information you want(the text between <text> and </text> tags) using  Perl Regular Expression:

data import (keep = line );
retain queName ;
retain line ;
set import0;

/*use PRX to capture the structure of XML data;*/
If _n_=1 then do;
queName=prxparse(‘/^<text> /’);
end;
queNameN=prxmatch(queName,line);

/*use PRX to remove the XXML tags;*/
if queNameN>0 then do;
rx1=prxparse("s/<.*?>//");
call prxchange(rx1,99,line);
output;
end;
run;

The logic of PRX approach to process XML data is very simple and can be easily modified according to your needs:

• complicate and utilize the PRX codes to capture the hierarchical structure of XML data.
• remove XML tags and output the information to SAS dataset.

SAS公司员工

Chris Hemedinger 主要是EG模块,书《SAS for Dummies》作者

SAS Programming for Data Mining Applications oloolo 用BASE，STAT等等编程模块实现与EM同等功能的各种数据挖掘功能的算法

Statecompute WenSui Liu  关于市场研究，数据挖掘等等方面的, SAS, R,python等各种软件

SUGI CLUB 挑出各SUG的一些文章进行翻译，做少量补充，内容较广

anyjack       各种SAS技术，偏IT