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;
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.