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 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 10 Feb 2010 15:19:52 -0800
Reply-To:     Tom Abernathy <tom.abernathy@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Tom Abernathy <tom.abernathy@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Data Manipulation
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

Your problem is mainly in reading the data. You did not set a length for the variable SKU so it appears to have truncated it to 8 characters. 'E2345/E2' and 'D345/D34'

Also you could use the COUNTW function to count the number or words rather than counting the number of delimiter characters.

On Feb 10, 4:08 pm, SD <saurabhk...@gmail.com> wrote: > Hello Nathan, > > thanks, I did try what you suggested : the new code would look like > this ( replacing the a/b/c/d etc with real SKU) .. this is your > code .. > > data tt (rename = ( Sku1 = Sku )); > infile cards; > length sku1 $ 10; > input year country $ SKU $ original countft; > Value = count(sku , '/' ) + 1 ; > Original = Original / value; > Countft = Countft / Value; > do i=1 to value; > sku1=scan(sku,i,'/'); > output; > end; > drop i value sku ; > cards; > 2009 germany E2345/E2346/E2347 40 20 > 2009 uk D345/D346/D347 30 6 > ; > > And the output I am getting is > SKU Year Country Original Counft > E2345 2009 germany 20 10 > E2 2009 germany 20 10 > D345 2009 uk 15 3 > D34 2009 uk 15 3 > > Some where I think I am missing something. > > SD > > On Feb 11, 12:11 am, SD <saurabhk...@gmail.com> wrote: > > > > > Thanks Nathan, Oleg, if I now replace SKU - a/b/c/d by E2345/E2346/ > > E2347, will it give the same results ? > > > thanks SD > > > On Feb 10, 7:25 pm, nathaniel.wood...@DOM.COM (Nathaniel Wooding) > > wrote: > > > > Here is a modification of Oleg's code that uses the V9 Count function which in this case tells us how many slashes appear in a particular SKU value. > > > > Nat wooding > > > > data tt (rename = ( Sku1 = Sku )); > > > infile cards; > > > length sku1 $ 10; > > > input year country $ SKU $ original countft; > > > Value = count(sku , '/' ) + 1 ; > > > Original = Original / value; > > > Countft = Countft / Value; > > > do i=1 to value; > > > sku1=scan(sku,i,'/'); > > > output; > > > end; > > > drop i value sku ; > > > cards; > > > 2009 germany a/b/c/d 40 20 > > > 2009 uk f/g/h 30 6 > > > ; > > > > -----Original Message----- > > > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of SD > > > Sent: Wednesday, February 10, 2010 5:49 AM > > > To: SA...@LISTSERV.UGA.EDU > > > Subject: Data Manipulation > > > > Hi everyone, > > > > i have a dataset > > > year country SKU original countft > > > 2009 germany a/b/c/d 40 20 > > > 2009 uk f/g/h 30 6 > > > > Want a dataset > > > year country SKU original countft > > > 2009 germany a 10 5 > > > 2009 germany b 10 5 > > > 2009 germany c 10 5 > > > 2009 germany d 10 5 > > > 2009 uk f 10 2 > > > 2009 uk g 10 2 > > > 2009 uk h 10 2 > > > > Need to scan , extract the SKUs -which I have been able to do, > > > however getting the number of SKU and dividing the number, that the > > > area , I digging. > > > > As you can see the numbers are divided by the count of SKUs in the SKU > > > column for Germany there are 4 skus and for UK there are 3, the values > > > of original and countft gets divided by 4 and 3 respectively. > > > > Any help appreciated. > > > > thanks > > > SD > > > CONFIDENTIALITY NOTICE: This electronic message contains > > > information which may be legally confidential and or privileged and > > > does not in any case represent a firm ENERGY COMMODITY bid or offer > > > relating thereto which binds the sender without an additional > > > express written confirmation to that effect. The information is > > > intended solely for the individual or entity named above and access > > > by anyone else is unauthorized. If you are not the intended > > > recipient, any disclosure, copying, distribution, or use of the > > > contents of this information is prohibited and may be unlawful. If > > > you have received this electronic transmission in error, please > > > reply immediately to the sender that you have received the message > > > in error, and delete it. Thank you.- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -


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