SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Help me in transposing some data Thanks

Reply
Contributor
Posts: 67

Help me in transposing some data Thanks

Hi Friends

i have attached an excel file please have a look if you can transpose this for me .

what i want this file to look like

Country                Country code     Year               GDP

Afghanistan                ---                     1999        ----

Afghanistan                                        2000          ----

and so on/....

alll the values given are GDP and i want them in one column instead 15.

THanks a lot for helping me .

Regards

Attachment
Frequent Contributor
Posts: 115

Re: Help me in transposing some data Thanks

Posted in reply to raqthesolid

Sorry not tested for the reason I am not sitting in front of my SAS software so my apologies that I can't test or give you a code that you can use as a verbatim. However on a first glance of your data from my cell phone, this is the code that comes to my mind:

Data want(drop= i /*and your year variable list*/);

set have;

array arrayname  _numeric_ ; /*assuming year variables are numeric- so easily grouped*/

do i=1 to dim(arraynme);

year=vname(arrayname(i));

GDP=arrayname(i);

output;

end;

run;

Please do the necessary changes accordingly and you should be able to make it to work for you. If the logic is wrong, my sincere apologies in advance

Thanks,

Naveen Srinivasan

L&T infotech.

Super Contributor
Posts: 490

Re: Help me in transposing some data Thanks

Posted in reply to raqthesolid

proc sort data=work.'gdp growth'n;

by country;

run;

proc transpose data=work.'gdp growth'n out=long1;

   by country code;

run;

proc print data=long1;

run;

But your data is strange you have multiple records for each country !!!

If each country have one record the above code will work

Ask a Question
Discussion stats
  • 2 replies
  • 290 views
  • 0 likes
  • 3 in conversation