BookmarkSubscribeRSS Feed
raqthesolid
Quartz | Level 8

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

2 REPLIES 2
naveen_srini
Quartz | Level 8

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.

mohamed_zaki
Barite | Level 11

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

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 808 views
  • 0 likes
  • 3 in conversation