Good aftenoon at all,
i need to create a new column mandatory in proc sql from a datasets where the existing column contains years in numbers.
here below my query that doesn't "run":
proc sql;
create table new as
select "31/12"!!year <--- the problem as MY_DATE
from old; /* where old db contains a variable "year" (year values are : 2000,2001,2002, etc - numerical format -)
quit;
I need to know how "to pass" correctly values of year.
Thanks in advance
massimo
a small demo if this may help:
data old;
do year=2000,2001,2002;
output;
end;
run;
proc sql;
create table new as
select "31/12/"!!put(year,8. -l) as MY_DATE
from old;
quit;
do you mean you are after
proc sql;
create table new as
select "31/12/"!!put(year,8. -l) as MY_DATE
from old; /* where old db contains a variable "year" (year values are : 2000,2001,2002, etc - numerical format -)
quit;
It is unclear what you are trying to do. Some actual data provided in the form of a data step and the desired result from that data would go a long way.
Without knowing much more, I would suggest your solution will involve the year() and/or the datepart() functions.
a small demo if this may help:
data old;
do year=2000,2001,2002;
output;
end;
run;
proc sql;
create table new as
select "31/12/"!!put(year,8. -l) as MY_DATE
from old;
quit;
Thanks a lot for the solution.
It works perfectly.
ciao
massimo
Apparently you are a mind reader.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.