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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 1081 views
  • 2 likes
  • 3 in conversation