BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dsrountree
Obsidian | Level 7

The following data was transposed:

PBP_NumberCategoryCodeCategoryDescriptionBenefitsentences_sort_orderStar_RatingEnrollmentindxidlabelTaborder
HXXXXX-019-07Dental ServicesCleaning (for up to 1 every six months): You pay nothing6233.5 out of 5 stars42442015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX19-021
HXXXXX-019-07Dental ServicesCleaning (for up to 1 every six months): You pay nothing6233.5 out of 5 stars42442015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesCleaning (for up to 1 every six months): You pay nothing6233.5 out of 5 stars1268232015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesCleaning (for up to 1 every six months): You pay nothing6233.5 out of 5 stars1268232015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesDental x-ray(s) (for up to 1 every six months): You pay nothing6563.5 out of 5 stars42462015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesDental x-ray(s) (for up to 1 every six months): You pay nothing6563.5 out of 5 stars42462015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesDental x-ray(s) (for up to 1 every six months): You pay nothing6563.5 out of 5 stars1268252015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesDental x-ray(s) (for up to 1 every six months): You pay nothing6563.5 out of 5 stars1268252015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesOral exam (for up to 1 every six months): You pay nothing7223.5 out of 5 stars42482015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesOral exam (for up to 1 every six months): You pay nothing7223.5 out of 5 stars42482015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesOral exam (for up to 1 every six months): You pay nothing7223.5 out of 5 stars1268272015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesOral exam (for up to 1 every six months): You pay nothing7223.5 out of 5 stars1268272015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesPreventive dental services:6223.5 out of 5 stars42412015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesPreventive dental services:6223.5 out of 5 stars42412015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-07Dental ServicesPreventive dental services:6223.5 out of 5 stars1268222015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-07Dental ServicesPreventive dental services:6223.5 out of 5 stars1268222015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes monitoring supplies: You pay nothing8023.5 out of 5 stars42412015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes monitoring supplies: You pay nothing8023.5 out of 5 stars42412015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes monitoring supplies: You pay nothing8023.5 out of 5 stars1268222015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes monitoring supplies: You pay nothing8023.5 out of 5 stars1268222015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes self-management training: You pay nothing8343.5 out of 5 stars42442015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes self-management training: You pay nothing8343.5 out of 5 stars42442015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes self-management training: You pay nothing8343.5 out of 5 stars1268232015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesDiabetes self-management training: You pay nothing8343.5 out of 5 stars1268232015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesTherapeutic shoes or inserts: You pay nothing8663.5 out of 5 stars42462015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesTherapeutic shoes or inserts: You pay nothing8663.5 out of 5 stars42462015~Benefit Plan Increased Benefits Plan (HMO)~424~3.5 out of 5 stars~HXXXXX-019-011
HXXXXX-019-08Diabetes Supplies and ServicesTherapeutic shoes or inserts: You pay nothing8663.5 out of 5 stars1268252015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-021
HXXXXX-019-08Diabetes Supplies and ServicesTherapeutic shoes or inserts: You pay nothing8663.5 out of 5 stars1268252015~Benefit Plan Increased Benefits Plan (HMO)~12682~3.5 out of 5 stars~HXXXXX-019-011

This data contains duplicate values in the BENEFIT column after I’ve indexed the columns to make sure the data is sorted according to sentences_sort_order.

I need to remove the duplicates much like you do in Excel after the columns are created.  Other PBP_Numbers when transposed don’t always contain duplicates in the BENEFIT column.

PROC TRANSPOSE DATA = Benefits Plan_HXXXXX_15 OUT = Benefits Plan_HXXXXX_15 PREFIX = ID_ ;

BY CategoryCode CategoryDescription indx;

var Benefit;

id PBP_Number ;

idlabel idlabel;

RUN;

PROC REPORT DATA = Benefits Plan _HXXXXX_15 spanrows nowd split='~';

columns CategoryCode CategoryDescription ID_:;

Define CategoryCode / order order=internal noprint;

define CategoryDescription / order 'Contract Year~Plan Name~Current Enrollment~Star Rating~Contract Number/PBP';

define ID_: / display;

compute after CategoryCode;

line ' ';

endcomp;

run;

Contract Year
Plan Name
Current Enrollment
Star Rating
Contract Number/PBP

2015
Benefits Plan (HMO)
424
3.5 out of 5 stars
HXXXXX-019-0

Dental Services

Preventive dental services:

Preventive dental services:

Cleaning (for up to 1 every six months): You pay nothing

Cleaning (for up to 1 every six months): You pay nothing

Dental x-ray(s) (for up to 1 every six months): You pay nothing

Dental x-ray(s) (for up to 1 every six months): You pay nothing

Oral exam (for up to 1 every six months): You pay nothing

Oral exam (for up to 1 every six months): You pay nothing

Diabetes Supplies and Services

Diabetes monitoring supplies: You pay nothing

Diabetes monitoring supplies: You pay nothing

Diabetes self-management training: You pay nothing

Diabetes self-management training: You pay nothing

Therapeutic shoes or inserts: You pay nothing

Therapeutic shoes or inserts: You pay nothing

I know when I added the additional data IE: Star_Rating & Enrollment via a left outer join this created my dups.

The problem is I can't do an inner since I need to make sure all the value(s) found in the left table remain in my extract and only pull a value when it finds a matching PBP_Number.

1 ACCEPTED SOLUTION

Accepted Solutions
dkb
Quartz | Level 8 dkb
Quartz | Level 8

Minor typo there - the option should be NOTSORTED .

View solution in original post

2 REPLIES 2
Reeza
Super User

Do it in a simple data step using the unsorted option?

data want;

set have;

by var1 var2 var3 var4 unsorted;

if first.var4;

run;

dkb
Quartz | Level 8 dkb
Quartz | Level 8

Minor typo there - the option should be NOTSORTED .

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!

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