Hello
I want to separate the numbers with slashes
the data i have is something like this 100287 211178
I tried the suggested solution on other threads, see below:
data want;
input datevar ddmmyy6.;
format datevar ddmmyys8.;
cards;160911
151111;
run;
however SAS converts it to a SAS date(?) so, 100287 becomes 300734 then formatting it with slashes it becomes 30/07/34, this is incorrect, I want to retain the values but separted only with slashes.
This works fine for me:
data HAVE;
input DATEVAR ddmmyy6.;
putlog DATEVAR= date9. DATEVAR= ddmmyys8.;
cards;
160911
151111
run;
DATEVAR=16SEP2011 DATEVAR=16/09/11
DATEVAR=15NOV2011 DATEVAR=15/11/11
Your code runs fine too, so you are doing something else.
@SuperSaiyan wrote:
hello thank you, it worked as expected, but is there any alternative for putlog? It was not taught in my class. is there a way to format it in proc print?
Proc print will work with your code out-of-the-box, just test it:
data want;
input datevar ddmmyy6.;
format datevar ddmmyys8.;
cards;
160911
151111
;
run;
proc print data=want noobs;
run;
The only thing I had to correct was the formatting of the cards; block.
Result:
datevar 16/09/11 15/11/11
Hi Rich Sorry I am new in SAS.Could you please explain me what is the use of putlog? Thanks in advance
put function shows log file at pdv
from source - pdv-ouput
you check
data ravi;
set sashelp.class;
if age=11 then status="chiled";
put _all_;
run;
The code you posted isn't going to run since you didn't put the data on separate lines from the CARDS: statement or the semi-colon that ends it. If we fix that
data want;
input datevar ddmmyy6.;
format datevar ddmmyys8.;
cards;
160911
151111
;
proc print;
run;
then it looks like it works.
Obs datevar 1 16/09/11 2 15/11/11
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.