BookmarkSubscribeRSS Feed
tom16
Calcite | Level 5
I have data set like this:

data b;
input custid emp $ age;
cards;
01 emp1 20
01 emp2 30
01 emp3 40
02 emp1 50
02 emp2 60
02 emp3 70
03 emp1 80
03 emp2 90
03 emp3 20
;
run;
and I wan to make it like this:
custid emp1 emp2 emp3 ;
01 20 30 40
02 50 60 70
03 80 90 20
;
I don't want to use Proc transpose....how can I do this........Please give quary..
7 REPLIES 7
R_Win
Calcite | Level 5
proc transpose data=b out=c(drop=_NAME_);
by custid ;
run;


And u can rename the remaniing varaibles col1=emp1 col2=emp2 col3=emp3
tom16
Calcite | Level 5
As I told you i don't want to use proc transpose...thanks
Ksharp
Super User
Although you do not want proc transpose (the best choice), then @data step will meet your taste.

[pre]
data b;
input custid emp $ age;
cards;
01 emp1 20
01 emp2 30
01 emp3 40
02 emp1 50
02 emp2 60
02 emp3 70
03 emp1 80
03 emp2 90
03 emp3 20
;
run;
proc sort data=b;
by custid;
run;
data op(drop=count emp age);
set b;
by custid;
array e{3} emp1 emp2 emp3;
retain emp1 emp2 emp3;
if first.custid then count=0;
count+1;
e{count} = age;
if last.custid then output;
run;

proc print noobs;run;
[/pre]



Ksharp
tom16
Calcite | Level 5
Hey KSHARP....

Yesterday I thought mail to you this one....I read your answers before in this forum....this work perfectelly fine.....you are the best...

Thanks,
data_null__
Jade | Level 19
Your specification is ambiguous.

Is EMP1 in CUSTID 1 the same as EMP1 in CUSTID 2, and in your real data are they equal.
tom16
Calcite | Level 5
Hi,

Thanks for yor answer...above ksharp give answer for this one and it work perfectelly fine...

Thanks Again.....
Ksharp
Super User
Hehe.Ok you can mail to me.
And also I think @data _null_; can do it better than me.That is just to post my solution before @data _null_; saw it.


Ksharp

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 989 views
  • 0 likes
  • 4 in conversation