BookmarkSubscribeRSS Feed
Pato485
Calcite | Level 5

Hello,

 

how can i transpose data if i have transposed data which first few words are the same, and this method take just few words at the start but now thole field, i got error:

ERROR: The ID value "'Dávka pre prípad hospitalizácie'n" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
K_PART=17 C_PZ=0304626732

But there are not the same words:

Pato485_0-1686213338841.png

There are more words like that, not the same, just the beggining of field is the same, and it just appear to be transposing it be few first letters in the field.

 

Is there a way how to take whole name and transpose it with whole name in the field (in my case it is field description).

 

Thank you.

 

P.

 

7 REPLIES 7
Kurt_Bremser
Super User

SAS variable names are limited to 32 characters, so your values cause a collision.

What are you trying to achieve? If this is for reporting, PROC REPORT is the right tool.

Pato485
Calcite | Level 5

i have to get all rows in description field to distinct columns... and if it is on the contract so there will be in field 1, so exampe 

Contract Mortgage Credit Card

1                 1                  1

2                

3                1

 

something like that.

Pato485
Calcite | Level 5

never heard of proc report. Can i use the data after in enterprise guide? To work with them after proc report? what is the base syntax pls?

Kurt_Bremser
Super User

"Working" with such variable names will be a catastrophic pain in the ass, and you should avoid it like hell.

All processing is much better done from a "long" dataset layout. "Wide" is only good for reporting purposes, and needed for a very limited number of tasks (regression analysis among them). For the latter, simpler variable names should be introduced, and your complex strings used as labels.

 

PROC REPORT will look like this:

proc report data=your_dataset;
column k_part c_pz description,hooo;
define k_part / group;
define c_pz / group;
define description / "" across;
define hooo / "" analysis;
run;
PaigeMiller
Diamond | Level 26

@Pato485 wrote:

i have to get all rows in description field to distinct columns... and if it is on the contract so there will be in field 1, so exampe 

Contract Mortgage Credit Card

1                 1                  1

2                

3                1

 

something like that.


How does this apply to the text fields that you showed originally? Why would you want those text strings as a variable name? Please EXPLAIN further.


SAS works best with long data sets, not wide data sets. Almost all SAS procedures expect long data sets, and wide data sets are much more difficult to work with.

--
Paige Miller
Tom
Super User Tom
Super User

You need to find (or create) another variable that you can use in the ID statement to set the new variable's NAME.

You can use the IDLABEL statement to tell PROC TRANSPOSE to use that DESCRIPTION variable as the new variable's LABEL instead.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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