Hello Everyone , i'm trying to add a year column with the value 2016 for each observation , this is what i tried but it didn't work.
Any Suggestion Would be Much Appreciated , thank you.
data DB_16;
set DB_16;
format Year Year4.;
Year = '2016'd;
run;
Why don't you try to just create a var with 2016 ?
data DB_16 ;
set DB_16 ;
year = 2016 ;
run ;
It will put 2016 on each observation
Try
data DB_16;
set DB_16;
retain Year 2016;
run;
Thank you , but that didn't work !!!
data a;
set a;
year=2016;
run;
The reason your original code didn't work is that "2016"d is not valid, when you enclose a text string in quotes and append a D after the last quote, this indicates to SAS that the value enclosed in the quotes is a text date in the format of 01JAN16. and then SAS will convert it to a valid SAS date. But your code had "2016"d which is not a date in the proper format.
Why don't you try to just create a var with 2016 ?
data DB_16 ;
set DB_16 ;
year = 2016 ;
run ;
It will put 2016 on each observation
Please post the log
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for 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.