Have table:
| ASTRAZENECA PLC | BARCLAYS PLC | BNP PARIBAS | |
| 10/22/2003 | 0.318770648 | 0.365655639 | 0.374383913 | |
| 10/23/2003 | 0.319576766 | 0.365696105 | 0.373288326 | |
| 10/24/2003 | 0.315151655 | 0.36529699 | 0.370542635 | |
| 10/27/2003 | 0.315135441 | 0.365901666 | 0.37086854 | |
| 10/28/2003 | 0.314288405 | 0.365839302 | 0.371058966 | |
| 10/29/2003 | 0.314282227 | 0.3640955 | 0.371062983 | |
| 10/30/2003 | 0.314280745 | 0.363681904 | 0.367175412 | |
| 10/31/2003 | 0.31502193 | 0.363453814 | 0.366553058 |
Want table:
| Date | Name | STD |
| 10/22/2003 | ASTRAZENECA PLC | 0.318771 |
| 10/23/2003 | ASTRAZENECA PLC | 0.319577 |
| 10/24/2003 | ASTRAZENECA PLC | 0.315152 |
| 10/27/2003 | ASTRAZENECA PLC | 0.315135 |
| 10/28/2003 | ASTRAZENECA PLC | 0.314288 |
| 10/29/2003 | ASTRAZENECA PLC | 0.314282 |
| 10/30/2003 | ASTRAZENECA PLC | 0.314281 |
| 10/31/2003 | ASTRAZENECA PLC | 0.315022 |
| 10/22/2003 | BARCLAYS PLC | 0.365656 |
| 10/23/2003 | BARCLAYS PLC | 0.365696 |
| 10/24/2003 | BARCLAYS PLC | 0.365297 |
| 10/27/2003 | BARCLAYS PLC | 0.365902 |
| 10/28/2003 | BARCLAYS PLC | 0.365839 |
| 10/29/2003 | BARCLAYS PLC | 0.364095 |
| 10/30/2003 | BARCLAYS PLC | 0.363682 |
| 10/31/2003 | BARCLAYS PLC | 0.363454 |
| 10/22/2003 | BNP PARIBAS | 0.374384 |
| 10/23/2003 | ASTRAZENECA PLC | 0.373288 |
| 10/24/2003 | ASTRAZENECA PLC | 0.370543 |
| 10/27/2003 | ASTRAZENECA PLC | 0.370869 |
| 10/28/2003 | ASTRAZENECA PLC | 0.371059 |
| 10/29/2003 | ASTRAZENECA PLC | 0.371063 |
| 10/30/2003 | ASTRAZENECA PLC | 0.367175 |
| 10/31/2003 | ASTRAZENECA PLC | 0.366553 |
Like this?
data have;
input Name:mmddyy10. ASTRAZENECA_PLC BARCLAYS_PLC BNP_PARIBAS;
format Name mmddyy10.;
datalines;
10/22/2003 0.318770648 0.365655639 0.374383913
10/23/2003 0.319576766 0.365696105 0.373288326
10/24/2003 0.315151655 0.36529699 0.370542635
10/27/2003 0.315135441 0.365901666 0.37086854
10/28/2003 0.314288405 0.365839302 0.371058966
10/29/2003 0.314282227 0.3640955 0.371062983
10/30/2003 0.314280745 0.363681904 0.367175412
10/31/2003 0.31502193 0.363453814 0.366553058
;
proc transpose data=have out=want(rename=(name=Date _NAME_=Name COL1=STD));
by Name;
run;
Like this?
data have;
input Name:mmddyy10. ASTRAZENECA_PLC BARCLAYS_PLC BNP_PARIBAS;
format Name mmddyy10.;
datalines;
10/22/2003 0.318770648 0.365655639 0.374383913
10/23/2003 0.319576766 0.365696105 0.373288326
10/24/2003 0.315151655 0.36529699 0.370542635
10/27/2003 0.315135441 0.365901666 0.37086854
10/28/2003 0.314288405 0.365839302 0.371058966
10/29/2003 0.314282227 0.3640955 0.371062983
10/30/2003 0.314280745 0.363681904 0.367175412
10/31/2003 0.31502193 0.363453814 0.366553058
;
proc transpose data=have out=want(rename=(name=Date _NAME_=Name COL1=STD));
by Name;
run;
Look at my answer to your other thread, there you see how it is solved with proc transpose.
Btw, is it a requirement to use SQL? Why not PROC TRANSPOSE?
SQL is a database language, and databases are not built in this way (data in structure). You could beat SQL into doing it with macro-preprocessing, but that would be stupid, considering that you just need 4 lines of proc transpose to achieve it.
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 save with the early bird rate—just $795!
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.