HI,
I am a bit stick with transposing data. would really appreciate your help with codes
this is what I have:
| TICKER | DATE | PRC |
| A | 2021-05-18 | 128.75 |
| A | 2021-05-19 | 130.21 |
| A | 2021-05-20 | 132.15 |
| AAPL | 2021-05-18 | 124.85 |
| AAPL | 2021-05-19 | 124.69 |
| AAPL | 2021-05-20 | 127.31 |
this is what I want:
| TICKER | 2021-05-18 | 2021-05-19 | 2021-05-20 |
| A | 128.75 | 130.21001 | 132.14999 |
| AAPL | 124.85 | 124.69 | 127.31 |
Having data in variable names is almost always a bad idea and leads to unnecessary complex code in further steps. "2021-05-18" is not a valid variable name. If you want a report as result using proc report with across-option for date you should get the layout.
For reporting purposes, use PROC REPORT:
data have;
input ticker $ date :yymmdd10. prc;
format date yymmdd10.;
datalines;
A 2021-05-18 128.75
A 2021-05-19 130.21
A 2021-05-20 132.15
AAPL 2021-05-18 124.85
AAPL 2021-05-19 124.69
AAPL 2021-05-20 127.31
;
proc report data=have;
column ticker prc,date;
define ticker / group;
define prc / "" analysis;
define date / "" across;
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.