DATA Step, Macro, Functions and more

Declaration of multiple arrays

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Declaration of multiple arrays

data k;
input name $ sales95 - sales99;
cards;
vandana 876 48 4 562 23
nandu 23 8763 36 3 234
roy 23 3 7863 3 32
john 23 5 7653 3 323
daniel 432 8654 4 234 234
run;

/*1 USD = 67.94 INR*/

/*please help me find the solution for the below question*/

/* keep both dollars and rupees with in a single dataset*/

/*data in the cards are in USD*/

 

/*i converted usd to inr using below code and it worked*/

 

/*how to  keep both dollars and rupees with in a single dataset*/

 

data k;
input name $ sales95 - sales99;
array vishnu(5) sales95-sales99;
do lilly=1 to 5;
vishnu(lilly)= vishnu(lilly)*67.94;
end;
drop lilly;
cards;
vandana 876 48 4 562 23
nandu 23 8763 36 3 234
roy 23 3 7863 3 32
john 23 5 7653 3 323
daniel 432 8654 4 234 234
run;

 

 


Accepted Solutions
Solution
‎01-16-2018 12:17 AM
Super Contributor
Posts: 500

Re: Declaration of multiple arrays

[ Edited ]
Posted in reply to VISHNU239

Please post code using {i} or running-man-icon.

 

You will have to create new variables to hold the converted values.

 

data k;
   length Name $ 20 Sales95-Sales99 Rupies95-Rupies99 8;
   input name $ sales95 - sales99;

   array vishnu(5) sales95-sales99;
   array rupies(5) Rupies95-Rupies99;

   do lilly=1 to 5;
      rupies(lilly) = vishnu(lilly) * 67.94;
   end;

   drop lilly;
   cards;
vandana 876 48 4 562 23
nandu 23 8763 36 3 234
roy 23 3 7863 3 32
john 23 5 7653 3 323
daniel 432 8654 4 234 234
;
run;

View solution in original post


All Replies
Solution
‎01-16-2018 12:17 AM
Super Contributor
Posts: 500

Re: Declaration of multiple arrays

[ Edited ]
Posted in reply to VISHNU239

Please post code using {i} or running-man-icon.

 

You will have to create new variables to hold the converted values.

 

data k;
   length Name $ 20 Sales95-Sales99 Rupies95-Rupies99 8;
   input name $ sales95 - sales99;

   array vishnu(5) sales95-sales99;
   array rupies(5) Rupies95-Rupies99;

   do lilly=1 to 5;
      rupies(lilly) = vishnu(lilly) * 67.94;
   end;

   drop lilly;
   cards;
vandana 876 48 4 562 23
nandu 23 8763 36 3 234
roy 23 3 7863 3 32
john 23 5 7653 3 323
daniel 432 8654 4 234 234
;
run;
Occasional Contributor
Posts: 17

Re: Declaration of multiple arrays

Posted in reply to andreas_lds

Thank you andreas_Ids. Got it.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 103 views
  • 1 like
  • 2 in conversation