Dear all,
I have a data set with the variable named mydate type=numeric, format=ddmmyyyy10.
Now I'd like to put all dates into one Makro variable:
proc sql noprint;
select distinct mydate into :datelist separated by " " from mydata order by mydate;
quit;
%put datelist;
Unfortunately proc sql uses the format so I get:
18/07/2013 19/07/2013 22/07/2013 23/07/2013
Yet, I'd like to have the values without the format. Can I tell proc sql "don't use the format" ?
(Because for example proc gplot doesn't use the formats either...)
Best wishes
Eva
Hello,
if you wish to use just the numeric values, which are used by SAS to represent the dates, you can simply add a numeric format such as best32. to view the unformatted values.
/*test*/
data mydata;
format mydate ddmmyy10.;
mydate='18sep2013'd;output; mydate='19sep2013'd;output;
run;
proc sql noprint;
select distinct mydate format best32. into :datelist separated by " " from mydata order by mydate;
quit;
%put &datelist;
/*gives 19619 19620*/
Hope it helps,
best regards Jakub
Hi Jakub,
yes, that's true I can transform it with a format. But like other procedures don't use the format I was thinking about a attribute maybe in the sql statement that tells the proc sql to generally not use the formats but the value as it is.
Best wishes
Eva
". . . .that tells the proc sql to generally not use the formats but the value as it is."
Isn't that what chrej5am has shown you?
You can read the SAS date variables into a macro variable list in many different ways (as integers, SAS date constants, or formatted text) . . .
not tested:
select distinct mydate format=best32. Into......
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.