LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 24 Feb 2009 13:57:40 -0500
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: String operations with Tranwrd

think that is a typical thing for a format:

proc format; value $state 'SC'='SOUTH CAROLINA.' 'MA'='MASSACHUSETTS.' 'AL'='ALABAMA.' 'AK'='ALASKA.' 'AZ'='ARIZONA.' 'AR'='ARKANSAS.' 'CO'='COLORADO.' 'CT'='CONNECTICUT.' 'DE'='DELAWARE.' 'FL'='FLORIDA.' 'GA'='GEORGIA.' 'HI'='HAWAII.' 'ID'='IDAHO.' 'IL'='ILLINOIS.' 'IN'='INDIANA.' 'IA'='IOWA.' 'KS'='KANSAS.' 'KY'='KENTUCKY.' 'LA'='LOUISIANA.' 'ME'='MAINE.' 'MD'='MARYLAND.' 'MI'='MICHIGAN.' 'MN'='MINNESOTA.' 'MS'='MISSISSIPPI.' 'MO'='MISSOURI.' 'MT'='MONTANA.' 'NE'='NEBRASKA.' 'NV'='NEVADA.' 'NH'='NEW HAMPSHIRE.' 'NJ'='NEW JERSEY.' 'NM'='NEW MEXICO.' 'NY'='NEW YORK.' 'NC'='NORTH CAROLINA.' 'OH'='OHIO.' 'OK'='OKLAHOMA.' 'OR'='OREGON.' 'PA'='PENNSYLVANIA.' 'RI'='RHODE ISLAND.' 'SD'='SOUTH DAKOTA.' 'TN'='TENNESSEE.' 'TX'='TEXAS.' 'UT'='UTAH.' 'VT'='VERMONT.' 'VA'='VIRGINIA.' 'WA'='WASHINGTON.' 'WV'='WEST VIRGINIA.' 'WI'='WISCONSIN.' 'WY'='WYOMING.' ; run;

data mail; infile datalines dlm=' ='; input st : $2.; length state $20; state = put(st,$state.); datalines; AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY, ; run;

Gerhard

On Tue, 24 Feb 2009 10:23:40 -0800, sasgeek009@GMAIL.COM wrote:

>I am trying to use Transwrd function to convert state code to full >state name and it is not working fine. For example : AL - Alabama, MS >- Mississippi, etc.. > >Here is the code.. > >data mail; >infile datalines dlm=' ,'; >input state $20.; >State = tranwrd(State,'AL','ALABAMA.'); >State = tranwrd(State,'AK','ALASKA.'); >State = tranwrd(State,'AZ','ARIZONA.'); >State = tranwrd(State,'AR','ARKANSAS.'); >State = tranwrd(State,'CO','COLORADO.'); >State = tranwrd(State,'CT','CONNECTICUT.'); >State = tranwrd(State,'DE','DELAWARE.'); >State = tranwrd(State,'FL','FLORIDA.'); >State = tranwrd(State,'GA','GEORGIA.'); >State = tranwrd(State,'HI','HAWAII.'); >State = tranwrd(State,'ID','IDAHO.'); >State = tranwrd(State,'IL','ILLINOIS.'); >State = tranwrd(State,'IN','INDIANA.'); >State = tranwrd(State,'IA','IOWA.'); >State = tranwrd(State,'KS','KANSAS.'); >State = tranwrd(State,'KY','KENTUCKY.'); >State = tranwrd(State,'LA','LOUISIANA.'); >State = tranwrd(State,'ME','MAINE.'); >State = tranwrd(State,'MD','MARYLAND.'); >State = tranwrd(State,'MA','MASSACHUSETTS.'); >State = tranwrd(State,'MI','MICHIGAN.'); >State = tranwrd(State,'MN','MINNESOTA.'); >State = tranwrd(State,'MS','MISSISSIPPI.'); >State = tranwrd(State,'MO','MISSOURI.'); >State = tranwrd(State,'MT','MONTANA.'); >State = tranwrd(State,'NE','NEBRASKA.'); >State = tranwrd(State,'NV','NEVADA.'); >State = tranwrd(State,'NH','NEW HAMPSHIRE.'); >State = tranwrd(State,'NJ','NEW JERSEY.'); >State = tranwrd(State,'NM','NEW MEXICO.'); >State = tranwrd(State,'NY','NEW YORK.'); >State = tranwrd(State,'NC','NORTH CAROLINA.'); >State = tranwrd(State,'OH','OHIO.'); >State = tranwrd(State,'OK','OKLAHOMA.'); >State = tranwrd(State,'OR','OREGON.'); >State = tranwrd(State,'PA','PENNSYLVANIA.'); >State = tranwrd(State,'RI','RHODE ISLAND.'); >State = tranwrd(State,'SC','SOUTH CAROLINA.'); >State = tranwrd(State,'SD','SOUTH DAKOTA.'); >State = tranwrd(State,'TN','TENNESSEE.'); >State = tranwrd(State,'TX','TEXAS.'); >State = tranwrd(State,'UT','UTAH.'); >State = tranwrd(State,'VT','VERMONT.'); >State = tranwrd(State,'VA','VIRGINIA.'); >State = tranwrd(State,'WA','WASHINGTON.'); >State = tranwrd(State,'WV','WEST VIRGINIA.'); >State = tranwrd(State,'WI','WISCONSIN.'); >State = tranwrd(State,'WY','WYOMING.'); > >datalines; > AL, >AK, >AZ, >AR, >CA, >CO, >CT, >DE, >FL, >GA, >HI, >ID, >IL, >IN, >IA, >KS, >ME, >MD, >MA, >MI, >MN, >MS, >MO, >MT, >NE, >NV, >NH, >NJ, >NM, >NY, >NC, >ND, >OH, >OK, >OR, >PA, >RI, >SC, >SD, >TN, >TX, >UT, >VT, >VA, >WA, >WV, >WI, >WY, >; >run; > > >Can someone help me with this...


Back to: Top of message | Previous page | Main SAS-L page