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!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.