11-04-2016 11:18 PM
Want to use variables first and last names from my data set to compute name in the form first, one space, last.
Want to call firstlast assigning length. Then using strip function.
Then i want to use name in the form last, a comma, one space, first. Calling it lastfirst and assigning appropriate length. and using strip function .
Data is :
obs Name first last
1 Rahul David Anand Rahul Anand
2 David Tel Merck Boxer David Boxer
3 Jim carney Ramsey Jim Ramsey
4 George Uday Yale George Yale
5 Frank Bates Frank Bates
6 Stacy Mary kim Coghlan Stacy Coghlam
my code which i am trying is not giving me accurate results :I would be grateful if anybody can assist.
length firstlast $50 ;
length lastfirst $50;
11-05-2016 12:44 AM
11-05-2016 12:53 AM
I asked a simple question. I know that i can read the documentation. Why you are replying like i am kid and don't know where to read and what to read. I just wanted help to get required results. I know every thing about scan and countw.And what you have suggested will never work.Let somebody else help me and you stay easy.Thanks
I interpreted your question incorrectly, but your response is childish.
Try using ', ' as the first argument to CATX for your second step.
Good luck and good bye.
11-05-2016 12:57 AM - edited 11-05-2016 01:01 AM
You have not post your results and what error you have.
I can't run your code now.
what is the error message ? usually SAs messages are clear enough to overcome.
You can use an alternative code:
firstlast = strip(first} || ' ' || strip(last);
lastfirst = strip(last) || ',' || strip(first);
11-05-2016 01:16 AM
11-05-2016 01:22 AM - edited 11-05-2016 01:26 AM
The message: Statement is not valid or it is used out of proper order.
menas that code is out of proper order. It should be like:
... enter any code ...
It seems that you submitted lines without the first two lines ?!
I got the error - you used different brackets : ( } instead ( )
11-05-2016 01:28 AM
11-05-2016 01:32 AM
your code should work too. @Reeza was right:
length lastfirst $50;
/* lastfirst=catx(' ',last,',',first); <<< replace with next line */
11-05-2016 01:42 AM
11-05-2016 02:15 AM
Just wanted to know if like in the data set there is a person who has 4 names and need to get his first middle name like David Tel Merck Boxer so Tel is his middle name , and there are people who have only two names so no middle is there or we can say there would be blank. So i want to create a variable middle with length $25 .So is that also possible , ?