[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Formating a date to a local macro variable

From   "Martin Weiss" <>
To   <>
Subject   st: AW: Formating a date to a local macro variable
Date   Fri, 17 Jul 2009 21:20:27 +0200




input  str10 mydate myvar	
13dec2007	7.45	
14dec2007	6.3	
17dec2007	6.25	
18dec2007	6.93	
19dec2007	7.2	
20dec2007	6.25	
21dec2007	7		     
27dec2007	6.7	
28dec2007	6.63
02jan2008	6.73	
03jan2008	6.63	
04jan2008	6.38	
07jan2008	6.45	
08jan2008	6.3	
09jan2008	6.18	


gen date=date(mydate, "DMY")
format date %tdMonth_DD,_CCYY

/*automatically quietly */ 
su date if myvar<7, mean

local date: disp %tdMonth_DD,_CCYY r(mean)

di "`date'"


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Susheel Patil
Gesendet: Freitag, 17. Juli 2009 21:11
An: ''
Betreff: st: Formating a date to a local macro variable

I have a variable "date" that contains the date that a particular assay was
run (the variable is in a data format). I would like to assign the date in a
particular observation to a local macro variable (its the same date for all
observations). Currently when it does this it assigns it a number in stata
date format relative to Jan 1, 1960. Is there a way to assign it to the
local macro variable in a way that it will formatted in a "readable" date

		quietly sum date if tmp_dp ==`i'
		local date = r(mean)



Susheel P. Patil, M.D., Ph.D.
Assistant Professor of Medicine
Johns Hopkins Sleep Disorders Center
Asthma and Allergy Center
5501 Hopkins Bayview Circle, Room 4B.41
Baltimore, MD 21224
Phone: 410-550-2335

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index