BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
max_ros
Obsidian | Level 7

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

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;
HB
Barite | Level 11 HB
Barite | Level 11

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.  

 

 

novinosrin
Tourmaline | Level 20

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;
max_ros
Obsidian | Level 7

Thanks a lot for the solution.

It works perfectly.

ciao

massimo

 

 

HB
Barite | Level 11 HB
Barite | Level 11

Apparently you are a mind reader.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 5 replies
  • 1649 views
  • 4 likes
  • 3 in conversation