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
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.