BookmarkSubscribeRSS Feed
Jahanzaib
Quartz | Level 8

Dear Tom, I know this is not right place to post my query. But i need your help if you please. I am attaching files that i need to transform same like the sample file present in the attachment. Can you please help me with the procedure. I shall be thankful to you.

2 REPLIES 2
Tom
Super User Tom
Super User

I "branched" this into a new topic.

Your data looks simple enough to use PROC TRANSPOSE.

Your BY variables should be FIRM and COUNTRY.

Your ID variable is VARIABLE.

And you can use _: to tell it to transform all of the _ variables.  In the output data set these variable names will be in the _NAME_ variable and the _LABEL_ value seems to have the actual YEAR value ('2005' for example is the label for the _005 variable).

BUT your FIRM/COUNTRY/VARIABLE combinations are NOT distinct.  For example FIRM='SUZA'.

Perhaps if you add another variable?

It seems to me that when VARIABLE='ROA' it is starting a new block of values.

Note that the values of VARIABLE could also be cleaned up to make them more consistent with each other and with your sample target table.

In Particular I found that some of the value have leading spaces.

So this little program let me at least transpose the data.

data fix_emerging;

set tmp3.emerging;

by firm country notsorted;

variable=LEFT(UPCASE(VARIABLE));

block+(first.country or variable='ROA');

run;

proc transpose data=fix_emerging out=want (rename=(_label_=year));

  by block firm country ;

  id variable ;

  var  _: ;

run;

Jahanzaib
Quartz | Level 8

many many Thanks dear TOM it is done.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 811 views
  • 1 like
  • 2 in conversation