|
|
date extraction
Hi I want to extract each date from Qdates get the data corresponding
to that date from all dataset and output it
to a file with a sheet named according to the date. I am a bit stuck
on how to do this below is what i am trying.
Thanks for all your help
%let Qdates = ('29-Apr-2005', '30-Jun-2005', '30-Sep-2005');
%macro extractdate;
%do %while(i<=3);
data tmp;
set all;
if date = Qdates(i);
run;
PROC EXPORT DATA= tmp
OUTFILE= "C:\temp.xls"
DBMS=EXCEL REPLACE;
SHEET=Qdates(i);
RUN;
%let i = &i+1;
%end;
%mend;
|
|
0
|
|
|
|
Reply
|
hd
|
12/13/2010 8:54:29 PM |
|
On Dec 13, 12:54=A0pm, hd <heen...@gmail.com> wrote:
> Hi I want to extract each date from Qdates get the data corresponding
> to that date from all dataset and output it
> to a file with a sheet named according to the date. I am a bit stuck
> on how to do this below is what i am trying.
> Thanks for all your help
>
> %let Qdates =3D ('29-Apr-2005', '30-Jun-2005', '30-Sep-2005');
>
> %macro extractdate;
>
> %do %while(i<=3D3);
> data tmp;
> set all;
> if date =3D Qdates(i);
> run;
>
> PROC EXPORT DATA=3D tmp
> =A0 =A0 =A0 =A0 =A0 =A0 =A0OUTFILE=3D "C:\temp.xls"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 DBMS=3DEXCEL REPLACE;
> =A0 =A0 =A0 =A0SHEET=3DQdates(i);
> RUN;
>
> %let i =3D &i+1;
> %end;
>
> %mend;
I didn't know that you could access a macro variable list like an
array...
it doesn't work for me, ie %put &qdates(i) doesn't return the i'th
variable in the list.
This does however:
%let Qdates =3D ('29Apr2005'd '30Jun2005'd '30Sep2005'd);
%put &qdates;
%put %scan(&qdates,1);
HTH,
Reeza
|
|
0
|
|
|
|
Reply
|
Reeza
|
12/13/2010 10:54:30 PM
|
|
>"hd" wrote in message
>news:7f960f4d-9dae-4706-a130-f90f1468b1ff@p11g2000vbn.googlegroups.com...
>Hi I want to extract each date from Qdates get the data corresponding
>to that date from all dataset and output it
>to a file with a sheet named according to the date. I am a bit stuck
>on how to do this below is what i am trying.
>Thanks for all your help
>%let Qdates = ('29-Apr-2005', '30-Jun-2005', '30-Sep-2005');
>%macro extractdate;
>%do %while(i<=3);
>data tmp;
>set all;
>if date = Qdates(i);
>run;
>PROC EXPORT DATA= tmp
> OUTFILE= "C:\temp.xls"
> DBMS=EXCEL REPLACE;
> SHEET=Qdates(i);
>RUN;
>%let i = &i+1;
>%end;
>%mend;
Your program is wrong in so many aspects. First of all, who told you that
&Qdate is an array? Second of all, %let is a string statement so
>%let i = &i+1;
will give you, instead of i = 2, you'd have i equals to "1+1" so nothing
makes sense.
Why don't you just process one date at a time and pass the date value into
the macro function? Then all you have to do is call the macro three times?
Finally, SAS date constant is in the format "29Apr2005"d. I don't know your
data so I have no ideas whether you are storing the dates as a string or as
numeric.
|
|
0
|
|
|
|
Reply
|
Kenneth
|
12/14/2010 12:53:43 AM
|
|
I am thinking you can use the table of Qdate list LEFT JOIN the other
table.
|
|
0
|
|
|
|
Reply
|
palapara
|
12/14/2010 4:17:00 PM
|
|
|
3 Replies
266 Views
(page loaded in 0.049 seconds)
Similiar Articles: date extraction - comp.soft-sys.sasHi I want to extract each date from Qdates get the data corresponding to that date from all dataset and output it to a file with a sheet named acc... Extracting Week from Date Variable - comp.soft-sys.stat.spss ...Hi Everyone, I need some help in extracting week from date variable in SPSS. I have one variables (datex) which contains the some date values, i try to extract the ... data extraction from large datafile - comp.soft-sys.matlab ...How do I extract a finite number of rows/columns from a large data file into a variable? Eg I have a data file which is a 10000x 2 array. I onl... Extracting single point data from matlab figure - comp.soft-sys ...I'm sure this is a simple problem, but i can't think how to do it. In one figure i have the derivative of a function. I can use "min" to extract th... Extracting data from sar - comp.unix.solarisHi: Can you tell me if is there any way to extract data from sar command and format this output like below solaris> sar -d | head SunOS sol001 5.8... Possible to extract data matrix from plot figure? - comp.soft-sys ...Hi! I have a somewhat silly question I think... If you have a matlab figure (.fig) containing a 2D plot, is it possible to extract the matrix of X ... Extracting data from plot figures? - comp.soft-sys.matlab ...Hello all! My problem this time concerns the extracting of data out of plot figures. I have saved several plots of elapsed time (y axis) and number... Extracting data from a 2D surface plot in Matlab - comp.soft-sys ...Hi, I have a 2D surface plot in Matlab depicting concentration values at any point on the surface. Was wondering how I could extract the data for ... Extracting a matrix from disorganised data file - comp.soft-sys ...Hi everyone, I have a bunch of data files produced by a script that acquires data in an experiment. A sample data file is located here: http://www.... Extracting data - comp.databases.ms-accessHere is the result of a query. This query was created using 2 temporary tables which hold every combined total of a number of payments ( I have allo... Data extraction - Wikipedia, the free encyclopediaData extraction is the act or process of retrieving data out of (usually unstructured or poorly structured) data sources for further data processing or data storage ... date fruit products, dried date, date extract, date concentrate ...PRODUCT NAME : Date Extract: PRODUCT CODE : 0404 DESCREPTION : water soluble extract of date fruit processed under controlled conditions USAGE : 7/25/2012 11:58:44 PM
|
|
|
|
|
|
|
|
|