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
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.
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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.