LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 8 Feb 2004 16:29:43 GMT
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Date series (NEWBIE)

Not sure precisely what you are trying to accomplish. According to your code, the two variables 'companies' and 'dates' are both dates. If that is so, and you want a record for every date, then why not first build a file which contains all dates? Then, within the merge, you could use "in=" to capture both what you have and what you are missing. For example,

data alldates; gc='01JAN1999'd; do until (gc gt '31DEC2003'd); output; gc+1; end; run; data dates; gc='01JAN1999'd;output; gc='01FEB1999'd;output; gc='02FEB1999'd;output; run; data companies; gc='01JAN1999'd;stockprices=15;output; gc='01FEB1999'd;stockprices=16;output; gc='02FEB1999'd;stockprices=17;output; run; proc sort data = dates; by gc; proc sort data = companies; by gc; data combined; retain holdstocks; merge alldates (in=alldates) dates (in=dates) companies (in=companies); by gc; if alldates; if dates then holdstocks=stockprices; run;

Art ---------- "Microstructure" <randistan69@hotmail.com> wrote in message news:751633cc.0402080613.138dd448@posting.google.com... > I have a masterfile of trading days from jan 1 1999 to Dec 31 2003. > In the second file I have companies and their stock prices stacked on > top of eaxh other...However, some days there has been no > trading...these days do NOT appear in the companies file. I want to > insert those days on which there has been no trading. I think that I > can do it using the masterfile of trading days. I merged the master > file of trading days and the company file. It does not seem to work > as there is no insertion of the days on which no trading took place. > > Here is the code I wrote > > data dates; set dates; > dates = gc > run; > > data companies; set companies; > /* dates also appears in this data file..however, only those days on > which trading takes place are included */ > companies = gc; > run; > > proc sort data = dates; by gc; > proc sort data = companies; by gc; > data combined; > merge dates > companies; > by gc; > > data combined1; set combined; > if dates = gc or companies = gc then output; > run; > > > Please help


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