BookmarkSubscribeRSS Feed
pp2014
Fluorite | Level 6

data have;

input start_dt mmddyy10. calls 3.;

datalines;

10/26/2015 10

11/02/2015 12

11/09/2015 10

11/16/2015 8

;

proc sort data=have;

by start_dt;

run;

 

proc transpose data =have out=want (drop=_name_);

id start_dt;

var Calls;

run;

 

It gives me output as below:

 

_10_26_2015 _11_02_2015    _11_09_2015    _11_16_2015

      10                        12                  10                    8

 

But I want the Output as follows:

 

10/26/2015     11/02/2015         11/09/2015          11/16/2015

     10                       12                   10                     8

4 REPLIES 4
slchen
Lapis Lazuli | Level 10

After transposed, date became variable name, in SAS, variable name is not allowed with digit at the first letter, and '/' is not allowed, but '_ ' is Ok. You could use label in transpose, such as:


proc transpose data =have out=want (drop=_name_);
id start_dt;
var Calls;
label _10_26_2015='10/26/2015';
run;

Reeza
Super User

 Those wouldn't be valid SAS variable names.

 

You can apply them as labels though by adding the IDLABEL line to your proc transpose code.

 

idlabel start_dt;
ballardw
Super User

That approach generates a real ugly dataset for much use. What will you do with the transposed data?

 

You you are looking for a pretty table appearance then use a report procedure such as Proc Report or tabulate.

PGStats
Opal | Level 21

"10/26/2015" is not a valid SAS variable name. Anyway, that's not what you get with the code you posted. You can use IDLABEL=

 

data have;
input start_dt mmddyy10. calls 3.;
format start_dt mmddyy10.;
datalines;
10/26/2015 10
11/02/2015 12
11/09/2015 10
11/16/2015 8
;
proc sort data=have;
by start_dt;
run;
 
proc transpose data =have out=want (drop=_name_);
id start_dt;
idlabel start_dt;
var Calls;
run;
PG

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1395 views
  • 0 likes
  • 5 in conversation