DATA CAPITALIZE;
INFORMAT FIRST LAST $30.;
INPUT FIRST $ LAST $;
FIRST = LOWCASE(FIRST);
LAST = LOWCASE(LAST);
SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1));
SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1));
DATALINES;
ronaldcODy
THomaSeDISON
alberteinstein
;
run;
Just follow the code you submitted in your most recent example.
DATA CAPITALIZE; INFORMAT FIRST LAST $30.; INPUT FIRST $ LAST $; FIRST = LOWCASE(FIRST); LAST = LOWCASE(LAST); SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1)); SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1)); DATALINES; ronaldcODy THomaSeDISON ; run;
You're reading one record that has two strings:
first=ronaldcODy and last=THomaSeDISON
You're then making all of the letters, of both, to be lower case. i.e.,
ronaldcody and thomasedison
You're then make the first letter, of each, to be uppercase:
Ronaldcody and Thomasedison
Art, CEO, AnalystFinder.com
Why not just run it and see for yourself?
I agree with @WarrenKuhfeld however, before running the code, suggest that you add a space between first and last names as shown in the example from Ron's book:
DATA CAPITALIZE; INFORMAT FIRST LAST $30.; INPUT FIRST $ LAST $; FIRST = LOWCASE(FIRST); LAST = LOWCASE(LAST); SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1)); SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1)); DATALINES; ronald cODy THomaS eDISON albert einstein ; run;
Art, CEO, AnalystFinder.com
my doubts here:
1.number of variables are four or two
2.i am get first,last,r,t
3.we get four variable and theri answer like this==first(ronaldcody),last(thomasedison),r=R,t=T
4.but i get only two variable FIRST=Ronaldcodv, LAST=Thomasedison
5.i want explain for this
DATA CAPITALIZE;
INFORMAT FIRST LAST $30.;
INPUT FIRST $ LAST $;
FIRST = LOWCASE(FIRST);
LAST = LOWCASE(LAST);
SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1));
SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1));
DATALINES;
ronaldcODy
THomaSeDISON
alberteinstein
;
run;
This code does not create variable R and T. You must be referring to some other program. SAS goes to a new line when it does not find Last on the same line as First. This works fine in the first pass but not in the second pass where you get a lost card error.
DATA CAPITALIZE;
INFORMAT FIRST LAST $30.;
INPUT FIRST $ LAST $;
FIRST = LOWCASE(FIRST);
LAST = LOWCASE(LAST);
SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1));
SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1));
DATALINES;
ronaldcODy THomaSeDISON
;
run;
I AM CONFUSE OUTPUT OF THIS PROGRAM
FIRST=Ronalddcody, LAST=Thomasedison
kindly explain
As @art297 pointed out, you left out the blanks. SAS reads the first line as the first name then the second line as the last name. The code capitalizes the first letter of each and lowercases the rest. Then SAS tries again and ends since it cannot find a last name (as I mentioned before). SAS continues to the next line when it can't find all the input on the current line.
Just follow the code you submitted in your most recent example.
DATA CAPITALIZE; INFORMAT FIRST LAST $30.; INPUT FIRST $ LAST $; FIRST = LOWCASE(FIRST); LAST = LOWCASE(LAST); SUBSTR(FIRST,1,1) = UPCASE(SUBSTR(FIRST,1,1)); SUBSTR(LAST,1,1) = UPCASE(SUBSTR(LAST,1,1)); DATALINES; ronaldcODy THomaSeDISON ; run;
You're reading one record that has two strings:
first=ronaldcODy and last=THomaSeDISON
You're then making all of the letters, of both, to be lower case. i.e.,
ronaldcody and thomasedison
You're then make the first letter, of each, to be uppercase:
Ronaldcody and Thomasedison
Art, CEO, AnalystFinder.com
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.