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.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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