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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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