tag:blogger.com,1999:blog-2315822260943695633.post5766192130011493262..comments2024-03-09T03:56:41.825-05:00Comments on StudySAS Blog: HOW TO USE THE SCAN FUNCTION:Unknownnoreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2315822260943695633.post-88705533894611618312017-07-08T19:59:16.896-04:002017-07-08T19:59:16.896-04:00The default length of the return value of SCAN is ...The default length of the return value of SCAN is actually the length of the first argument, rather than 200. (This is different from the default behavior of the CAT family of functions, where the length of the returned argument is indeed 200.)David Grinsteinhttps://www.blogger.com/profile/05351599189906318348noreply@blogger.comtag:blogger.com,1999:blog-2315822260943695633.post-45757874077005737502016-04-20T06:02:20.123-04:002016-04-20T06:02:20.123-04:00How I shoul replace a char with num and num with c...How I shoul replace a char with num and num with char in a given example Variable date contains observations <br /> 01:unk:2009 <br /> unk:01 2010<br /><br />Unk shud replace with 'jan' in 1st observation<br />Unk in 2 nd observation shud replace by 15<br /><br />Usin char function<br /><br />Can anybody help pleaseAnonymoushttps://www.blogger.com/profile/11882050843564408620noreply@blogger.comtag:blogger.com,1999:blog-2315822260943695633.post-16313199057408109232013-09-23T16:04:41.301-04:002013-09-23T16:04:41.301-04:00Hi Shan,
I don't know how to sort the values ...Hi Shan,<br /><br />I don't know how to sort the values using the SCAN function. But using the Call Sortc routine you can do this.<br /><br />Here is the code.<br /><br />data test;<br />length cars $200;<br />input cars $1-50;<br />cards;<br />chevy, ford, chyrsler, alpha romeo,<br />toyota, mazada, studebaker, <br />ford, ford, chevy, BMW,<br />;<br />run;<br /><br /><br />data test1;<br />set test;<br /> car1 = scan(CARS,1,",");<br /> car2 = scan(CARS,2,",");<br /> car3 = scan(CARS,3,",");<br /> car4 = scan(CARS,4,",");<br /> array x(*) $ car1 car2 car3 car4;<br /> call sortc(of x(*));<br />run; <br /><br />Let me know if you have any questions.<br /><br />Sarathsarathhttps://www.blogger.com/profile/00356864575673246046noreply@blogger.comtag:blogger.com,1999:blog-2315822260943695633.post-71842519142866356552013-09-23T14:19:23.212-04:002013-09-23T14:19:23.212-04:00Seems like it won't work when the delimiter is...Seems like it won't work when the delimiter is more than one character?<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2315822260943695633.post-72914584317973108252013-01-30T17:05:04.889-05:002013-01-30T17:05:04.889-05:00Hi,
a google search for 'sas scan alphabetica...Hi,<br /><br />a google search for 'sas scan alphabetical' led me to your blog.<br /><br />which me to ask a question regarding scan function. is there anyway for scan to return an alphabetical component listing. <br />e.g.,<br />the study is to list all cars at a specific 4-way stoplight on a multi-lane road (pure fictional exmple!)<br /><br />variable is 'CARS'<br />data lines listed as CARS looks like this:<br /><br />chevy, ford, chyrsler, alpha romeo;<br />toyota, mazada, studebaker, ;<br />ford, ford, chevy, BMW;<br />etc..<br /><br />car1 = scan(CARS,1,",");<br />car2 = scan(CARS,2,",");<br />car3 = scan(CARS,3,",");<br />car4 = scan(CARS,4,",");<br />etc..<br /><br />what I would like is the have scan do is to ensure that 'car1' always has the alphabetical first from the list of cars in the multi-listed variable CARS.<br /><br />so results would look like this:<br /><br />cars1 cars2 cars3 cars4<br />alpha romeo chevy chrysler ford<br />mazada studebaker toyota <br />BMW chevy ford ford<br /><br />thanks<br />shan<br />shan8299@gmail.comAnonymoushttps://www.blogger.com/profile/14614955285352436680noreply@blogger.comtag:blogger.com,1999:blog-2315822260943695633.post-35723824279145994142008-08-27T09:24:00.000-04:002008-08-27T09:24:00.000-04:00note to the folks playing along at home -- make su...note to the folks playing along at home -- make sure you pad the datalines in this code so that the phone number starts at column 21. it won't work right if you copy and paste it directly (like i just did...). :-PKevin Stanfordhttps://www.blogger.com/profile/16197488814385643351noreply@blogger.com