Hello
Why mon field is not calculated correctly
data tbl1807;
input x;
cards;
1
2
3
;
run;
data tbl1806;
input x;
cards;
4
5
;
run;
data tbl1712;
input x;
cards;
7
8
9
;
run;
data combined;
set tbl1807 tbl1806 tbl1712 indsname=ds;
length mon $5;
mon=substr(scan(ds,3,','),5);
run;
Just run this:
data combined;
set tbl1807 tbl1806 tbl1712 indsname=ds;
dsname = ds;
run;
and you'll see why both the scan() and the substr() in your code:
data combined;
set tbl1807 tbl1806 tbl1712 indsname=ds;
length mon $5;
mon=substr(scan(ds,3,','),5);
run;
can't work.
Maxim 3: Know your Data. Can be extended to "know your variables" 😉
Note that I changed the subject of your question. "SET" as a subject is not helpful for finding posts specific to an issue.
I assumed you are trying to extract numeric value of indsname.
data combined;
set tbl1807 tbl1806 tbl1712 indsname=ds;
dsname=ds;
mon=compress(dsname,,'ap');
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.