BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
I have a tsble thst looks like this
Cp_ID,
ID,
CONTENT,
ITEMCOUNT
LAST MODIFY
I DO A SORT content
Data looks like
Cpid. Id. Content. Count. Last modify
Cpid123. A2. One. 1864 20sep2018 17:54:02
Cpid123. A2. Two 20 20sep2018 17:36:09
Cpid123. A2. Five. 543 20sep2018 17 59:04
Cpid123. A2. Ten. 67 20sep2018 17:38:16
Cpid123. A2. One. 500 19sep2018 16:33:08
Cpid123. A2. Two 200 19sep2018 17:49:12
I need the proc transposed to look

Cpid. Id. Date. . One. Two five ten
1 ACCEPTED SOLUTION

Accepted Solutions
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

 

here is the transpose you are requesting:

data have;
input Cp_ID $
ID $
CONTENT $
ITEMCOUNT
LAST :date9. MODIFY $;
cards;
Cpid123. A2. One. 1864 20sep2018 17:54:02
Cpid123. A2. Two 20 20sep2018 17:36:09
Cpid123. A2. Five. 543 20sep2018 17:59:04
Cpid123. A2. Ten. 67 20sep2018 17:38:16
Cpid123. A2. One. 500 19sep2018 16:33:08
Cpid123. A2. Two 200 19sep2018 17:49:12
;
proc sort data=have;
	by cp_id id last modify;
run;
proc transpose data=have out=want(drop=_name_);
   by cp_id id last modify;
   id content;
   var itemcount;
   format last date9.;
run;
proc print data=want;run;

 

 

View solution in original post

7 REPLIES 7
Reeza
Super User

You can use the methods here to provide sample data in a format that others can easily use:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

 

Gil_
Quartz | Level 8
I didnt know it posted i was getting and error message sorry
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

 

here is the transpose you are requesting:

data have;
input Cp_ID $
ID $
CONTENT $
ITEMCOUNT
LAST :date9. MODIFY $;
cards;
Cpid123. A2. One. 1864 20sep2018 17:54:02
Cpid123. A2. Two 20 20sep2018 17:36:09
Cpid123. A2. Five. 543 20sep2018 17:59:04
Cpid123. A2. Ten. 67 20sep2018 17:38:16
Cpid123. A2. One. 500 19sep2018 16:33:08
Cpid123. A2. Two 200 19sep2018 17:49:12
;
proc sort data=have;
	by cp_id id last modify;
run;
proc transpose data=have out=want(drop=_name_);
   by cp_id id last modify;
   id content;
   var itemcount;
   format last date9.;
run;
proc print data=want;run;

 

 

Gil_
Quartz | Level 8
Reeza i cant copy and post my actual code restrictions
Reeza
Super User

Then make fake data or use a dataset from SASHELP.CLASS. 


@Gil_ wrote:
Reeza i cant copy and post my actual code restrictions

 

Gil_
Quartz | Level 8
Hi VOD, it partial work its seems to be missing 2entries.
Cpid123. A2. One. 1844 20sep2018 23:54:02
Cpid123. A2. Two 1844 20sep2018 23:54:02 Cpid123. A2. Five. 1844 20sep2018 23:54:02

Cpid123. A2. One. 1244 20sep2018 17:38:16

Cpid123. A2. Two. 1244 20sep2018 17:38:16

Cpid123. A2. Five 1244 20sep2018 17:38:16

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 1796 views
  • 2 likes
  • 3 in conversation