Hi, new user here that is trying to learn the ropes. I have a question here, how do I convert table 1 to table 2? table 2 is to calculate the frequency of eg, number of times in year 2005, 2006.. where the index is 6.
table 1
Year | Index |
2005 | 5 |
2005 | 8 |
2005 | 11 |
2006 | 6 |
2007 | 13 |
2007 | 5 |
2007 | 6 |
2007 | 5 |
2008 | 8 |
2008 | 5 |
2008 | 5 |
table 2
2005 | 2006 | 2007 | 2008 | |
Index<6 | 1 | 0 | 2 | 2 |
Index=6 | 0 | 1 | 1 | 0 |
Index=8 | 1 | 0 | 0 | 1 |
Index>8 | 1 | 0 | 1 | 0 |
proc format;
value indx low-5='Index<6'
6='Index=6'
8='Index=8'
8-high='Index>8';
run;
proc freq data=table1;
table index*year/nocum nopercent norow nocol;
format index indx.;
run;
proc format;
value indx low-5='Index<6'
6='Index=6'
8='Index=8'
8-high='Index>8';
run;
proc freq data=table1;
table index*year/nocum nopercent norow nocol;
format index indx.;
run;
thanks pal! great help!
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.