Using SAS University Edition
How do i change a name linda Y. d'amora to a proper case name with the last name capital?
what am i doing wrong here?
data Uppercase;
set work.length;
String= upcase(String);
Name = propcase(Name);
run;
@Tom wrote:Is this some type of homework assignment? What have you attempted? How did it go? How was the result different than you wanted.
Also why did you go to the extra effort to take a PICTURE of your code and insert it into your message instead of just copying the TEXT of the code? Not only was that harder for you it marks it impossible for someone to help you by just making minor edits to your code.
Nevermind, I figured it out. Thanks for all your help!
yes, this is a homework assignment. I need the last name in the D'amore to say D'Amore. I am new to programming and don't know the best way to complete stuff. So this is a work in progress for me.
data Oscar;
length String $ 10 Name $ 20 Comment $25 Address $ 30 Q1-Q5 $ 1 ;
infile datalines dsd dlm= " ";
input String Name Comment Address Q1-Q5;
datalines;
AbC "jane E. MarPie" "Good Bad Bad Good" "25 River Road" y n N Y Y
12345 "Ron Cody" "Good Bad Ugly" "123 First Street" N n n n N
98x "Linda Y. d'amore" "No Comment" "1600 Penn Avenue" Y Y y y y
. "First Middle Last" . "21B Baker St." . . . Y N
;
*(2A)*Using the two length functions, compute the length of 'String' not counting
trailing blanks and the storage length of 'String'. Call these two variables L1 L2*;
data length;
set work.oscar;
L1=lengthn(String) + lengthn(String);
L2=lengthc(String) + lengthc(String);
findc(String, '2', '3')
run;
title 'Lengths of String';
proc print data=work.length;
run;
*(2B);
data Uppercase;
set work.length;
String= upcase(String);
Name = propcase(Name);
run;
title "Modified Program of Character Cases";
proc print data=work.uppercase;
run;
so when I run it like this, it does not change the D'amore to D'Amore. That is what I am trying to do.
I have went back into the first part of the program and tried the
Name = Propcase(Name, " . ' ");
String = upcase(String);
it worked after I made some corrections.
Please post more examples of what you have and of what you want.
Please post a test date in the form of (use the running man icon on top):
data test;
infile datalines;
input name $20.;
datalines;
<string1>
<string2>
...
run;
this is the program I started with
I am supposed to modify the program so that String is in uppercase and Name is in proper case.. Use appropriate delimiters so the name d'amore is spelled D'Amore.
Function propcase has some limitations, one of which is not handling apostrophes properly (no pun)
71 data _null_; 72 name = "jean-pierre d'entremont"; 73 pName = propcase(name); 74 put _all_; 75 run; name=jean-pierre d'entremont pName=Jean-Pierre D'entremont _ERROR_=0 _N_=1
this is the program I started with.
I am supposed to modify the program so that String is in uppercase and Name is in proper case. Using appropriate delimiters so that the name d'amore is spelled D'Amore.
Is this some type of homework assignment? What have you attempted? How did it go? How was the result different than you wanted.
Also why did you go to the extra effort to take a PICTURE of your code and insert it into your message instead of just copying the TEXT of the code? Not only was that harder for you it marks it impossible for someone to help you by just making minor edits to your code.
@Tom wrote:Is this some type of homework assignment? What have you attempted? How did it go? How was the result different than you wanted.
Also why did you go to the extra effort to take a PICTURE of your code and insert it into your message instead of just copying the TEXT of the code? Not only was that harder for you it marks it impossible for someone to help you by just making minor edits to your code.
Nevermind, I figured it out. Thanks for all your help!
yes, this is a homework assignment. I need the last name in the D'amore to say D'Amore. I am new to programming and don't know the best way to complete stuff. So this is a work in progress for me.
data Oscar;
length String $ 10 Name $ 20 Comment $25 Address $ 30 Q1-Q5 $ 1 ;
infile datalines dsd dlm= " ";
input String Name Comment Address Q1-Q5;
datalines;
AbC "jane E. MarPie" "Good Bad Bad Good" "25 River Road" y n N Y Y
12345 "Ron Cody" "Good Bad Ugly" "123 First Street" N n n n N
98x "Linda Y. d'amore" "No Comment" "1600 Penn Avenue" Y Y y y y
. "First Middle Last" . "21B Baker St." . . . Y N
;
*(2A)*Using the two length functions, compute the length of 'String' not counting
trailing blanks and the storage length of 'String'. Call these two variables L1 L2*;
data length;
set work.oscar;
L1=lengthn(String) + lengthn(String);
L2=lengthc(String) + lengthc(String);
findc(String, '2', '3')
run;
title 'Lengths of String';
proc print data=work.length;
run;
*(2B);
data Uppercase;
set work.length;
String= upcase(String);
Name = propcase(Name);
run;
title "Modified Program of Character Cases";
proc print data=work.uppercase;
run;
so when I run it like this, it does not change the D'amore to D'Amore. That is what I am trying to do.
I have went back into the first part of the program and tried the
Name = Propcase(Name, " . ' ");
String = upcase(String);
it worked after I made some corrections.
I found this on SAS documentation on functions and
I went back into the first part of the program and tried the
Name = Propcase(Name, " . ' ");
String = upcase(String);
it worked after I made some corrections.
Thanks for your response.
Re-reading the question was key as they provided the hint to the solution which you could find easily by reading the documentation.
You should remind your instructor that getting the right case of names is not that easy. Are you sure that "Linda Y. d'amore" actually uses D'Amore instead of d'Amore ,D'amore or d'amore?
Really, so I must be newer than a beginner. It is hard for me to remember all these functions.
Thanks for your help or response.
Best wishes
Robin
@slater1 wrote:
Really, so I must be newer than a beginner. It is hard for me to remember all these functions.
Thanks for your help or response.
Best wishes
Robin
No one remembers them ever, I look up the definitions every day, especially because i program in multiple languages and want to ensure that I'm remembering it correctly for the language I'm using that day.
Bookmark this page and when you need to do something, ie find a specific character that means use a character function. Then you click on character functions and see which one does what you want. If you're working with dates and want to know how to get the day of the month you would go to the Date & Time functions. Learning how to find things is more important.
EDIT: for example, I didn't know that PROPCASE takes a delimiter, but now I do, based on the code you used an a quick review of the documentation on that function.
Such as:
data have ;
input @1 Name $char32. ;
cards ;
jane E. MarPie
Jane e. marpie
Ron coDy
ron Cody
linda Y. d'amore of'love
Linda y. D'amore
Linda y. d'Amore
Linda y. De'Amore
Linda y. dE'Amore
FirSt miDDle last
f'firSt m'Middle lA'last
;
run ;
data want (drop = _:) ;
set have (rename=name=_nm) ;
name = _nm ; *set syslength;
name = "" ;
do _i = 1 to countw (_nm, "'") ;
name = catx ("'", name, propcase (scan (_nm, _i, "'"))) ;
end ;
run ;
Kind regards
Paul D.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.