Hello,
I have tables for 6 years 2012 to 2017
I have a list of codes in each table that I want to compare
Basically I want to create a table that tells me which codes have changed over the years?
E.g. if 1HA80QB is present from 2012 to 2016 and then it disappeared in 2017 i need to kow that
or a new code appeared in 2017 onwards which was not present in prior years?
How would i compare these 6 tables?
Please advise
Thanks
@Ranjeeta wrote:
How would I write the proc transpose
proc transpose data=combined (keep =fyear ccicode);
var fyear;
run;
most likely like this:
proc transpose data=have out=want prefix=Year; by Code; ID year; Var ; *what value you want to be transposed, may need to add one in previous step; run;
I meant append, not merge.
Untested obviously, but this is the idea.
data long;
set px2011-px2017 indsname = source;
name = source;
DummyVar=1;
run;
proc sort data=have;
by px_code name;
run;
proc transpose data=long out=wide prefix=Year_;
by px_code;
id name;
var DummyVar;
run;
data want;
set wide;
CountYears = sum(of year_:);
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.