BookmarkSubscribeRSS Feed
Eva
Quartz | Level 8 Eva
Quartz | Level 8

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

4 REPLIES 4
chrej5am
Quartz | Level 8

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

Eva
Quartz | Level 8 Eva
Quartz | Level 8

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

Fugue
Quartz | Level 8

". . . .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) . . .

Patrick
Opal | Level 21

not tested:

select distinct mydate format=best32. Into......

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3236 views
  • 0 likes
  • 4 in conversation