Help using Base SAS procedures

proc sql into without format

Reply
Regular Contributor
Regular Contributor
Posts: 156

proc sql into without format

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

Contributor
Posts: 42

Re: proc sql into without format

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

Regular Contributor
Regular Contributor
Posts: 156

Re: proc sql into without format

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

Super Contributor
Posts: 307

Re: proc sql into without format

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

Respected Advisor
Posts: 3,887

Re: proc sql into without format

not tested:

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

Ask a Question
Discussion stats
  • 4 replies
  • 654 views
  • 0 likes
  • 4 in conversation