Help using Base SAS procedures

Strange result in data step

Reply
Super Contributor
Posts: 359

Strange result in data step

Have I lost my mind or is somethin wrong here?

data _null_;
cur_yr = year(today());
cur_day = day(today());
cur_mnth = month(today());
x= catx(put(cur_mnth, z2.), put(cur_day, z2.), put(cur_yr, z4.));
y = compress(put(cur_mnth, z2.)|| put(cur_day, z2.) || put(cur_yr, z4.));
put 'HERE ' cur_mnth cur_day cur_yr ;
put x=;
put y=;
call symput('rundat8', catx(put(cur_mnth, z2.), put(cur_day, z2.), put(cur_yr, z4.)));
run;
%put &rundat8 ;

Results in
HERE 1 28 2011
x=28012011
y=01282011
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.00 seconds


33 %put &rundat8 ;
28012011

How is the CATX reversing the order of the values?
Same result in 9.1 on Unix and 9.2 on WIN 7
Regular Contributor
Posts: 165

Re: Strange result in data step

Check the catx syntax

CATX(separator, string-1 <, ...string-n>)

01 is being used as the separator for the other two strings.
Super Contributor
Posts: 359

Re: Strange result in data step

Thanks, I knew it had to be a Friday afternoon brain death.
Ask a Question
Discussion stats
  • 2 replies
  • 124 views
  • 0 likes
  • 2 in conversation