Hello SAS.
I need some help with following situation :
I have two tables :
NOCONT | prod | DPD_0 | DPD0 | CDSITC1 | DAT_REST | STARE1 | TOTAL11 | DPD_1 | DPD WCS | DPD1 | Scadenta |
500338833 | CR | 0 | B0. 0 | 1 | 20181015 | A | 2925.076 | 9 | 39 | B1. 1-30 | 22 |
and
NOCONT | DTCSTS03 |
5416257158 | 20180718 |
500338833 | 20180731 |
I want to add DTCSTS03 from second table to equivalent NOCONT in first table , also I need a modify the structure and format of DTCSTS03
I want to modify from 20180731 to 07/31/2018 and to replace de 31 with value of scadenta column.
in excel I use vlookup and DATE(LEFT(A2,4),RIGHT(LEFT(A2,6),2),RIGHT(A2,2)) date formula to make those changes , In SAS I didn't manage to create something near close.
Thank you in advance
Then do this:
data want;
merge
table_1 (in=a)
table_2 (
in=b
rename=(dtcsts03=_dtcsts03)
)
;
by nocont;
format dtcsts03 mmddyy10.;
if a;
if b then dtcsts03 = input(substr(put(_dtcsts03,8.),1,6) !! put(scadenta,z2.),yymmdd8.);
drop _dtcsts03;
run;
The tables have to be sorted by nocont, and scadenta is assumed to be a number; if it's character, omit the put() function around it.
Your new dtcsts03 will be a real, usable SAS date value.
We need more information about DTCSTS03:
Is it
?
DTCSTS03 is number format best12. informat best12.
Then do this:
data want;
merge
table_1 (in=a)
table_2 (
in=b
rename=(dtcsts03=_dtcsts03)
)
;
by nocont;
format dtcsts03 mmddyy10.;
if a;
if b then dtcsts03 = input(substr(put(_dtcsts03,8.),1,6) !! put(scadenta,z2.),yymmdd8.);
drop _dtcsts03;
run;
The tables have to be sorted by nocont, and scadenta is assumed to be a number; if it's character, omit the put() function around it.
Your new dtcsts03 will be a real, usable SAS date value.
thank you for your time
you are the best , I will add some things to database
if I will have problems I will contact you
thank you again
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.