Help using Base SAS procedures

Cal the obs and Macrotise the value

Reply
Regular Contributor
Posts: 229

Cal the obs and Macrotise the value

i am having a data set data main; input sal; cards; 100 200 run; data mon_sal; input days; cards; 2 3 run; %macro sas_cal; proc sql; select count(*) into :cou from mon_sal; select sal into s1-s&cou from main; quit; data mon_sal; set mon_sal; do i=1 %to &cou; mo_days=days*s&cou; %end; run; %mend; %sa_cal; I am trying to iterate it as the same calulation i want to do for few datasets i want the sal from one dataset and days from another datasets to create new variable how can i macro tise it output of mon_sal; days mo_days 2    200 3    600

Regular Contributor
Posts: 229

Re: Cal the obs and Macrotise the value

Ref this

Attachment
Super User
Super User
Posts: 6,500

Re: Cal the obs and Macrotise the value

This does not look like a problem where you would need to get into the complexity of MACRO programming.  Normal programming will do just fine.

It will probably work better if your two source datasets had some type of ID variable to identify the rows so that you can match the SAL to the proper DAYS.  Perhaps MONTH?

If you are willing to assume that the tables should match row by row then you can use merge without a BY statement or two independent SET statements to read one row from each source table per loop of the data step.

data main;

  input sal;

cards;

100

200

run;

data mon_sal;

  input days;

cards;

2

3

run;

data mon_sal;

  set main;

  set mon_sal;

   mo_days = days*sal;

run;

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