Sounds like the following would do what you want/need:
data want (drop=_:);
informat Block_Name $15.;
infile cards dlm='09'x;
input Block_Name No_of_auditors_required No_of_Villages No_of_IDs_required;
do _i=1 to No_of_auditors_required;
do _j=1 to No_of_Villages;
id=catt(Block_Name,_i,'_',_j);
output;
end;
end;
cards;
Badlapur 6 3 18
Barsathi 7 6 42
Bhitargaon 15 30 450
Bilhaur 26 63 1638
Chaubepur 20 45 900
Dharampur 27 66 1782
Dobhi 10 15 150
Ghatampur 15 30 450
Kakwan 17 36 612
Kalyanpur 20 45 900
Karanjakala 80 225 18000
KHUTHAN 8 9 72
Mahrajganj 34 87 2958
Mariahu 18 39 702
Rampur 7 6 42
Shahganj 66 183 12078
Shivrajpur 20 45 900
Sikrara 19 42 798
Sirkoni 30 75 2250
SUITHAKALA 12 21 252
;
HTH,
Art, CEO, AnalystFinder.com
What you want to do must be quite simple to achieve but as @Jagadishkatam points out your narrative of the problem doesn't match with the data you've provided. You need to clarify.
If the solution @art297 provided doesn't fit your requirements then just writing "it's not working" is insufficient. You need to explain what's not working as this will help us to understand what you're actually after.
Again: Your problem won't be hard to solve. It's all about you explaining us clearly what you have and what you need in order to enable us to provide a working solution.
I personally don't have R skills but there are quite a few very capable and experienced members in this forum so I'm sure posting existing R code logic will help to illustrate what you're after.
Here is the solution but in R programming. So can you please change it to SAS programming.
Block <- c("Badlapur","Barsathi","Bhitargaon","Bilhaur","Chaubepur","Dharampur",
"Dobhi","Ghatampur","Kakwan","Kalyanpur","Karanjakala","KHUTHAN",
"Mahrajganj","Mariahu","Rampur","Shahganj","Shivrajpur","Sikrara",
"Sirkoni","SUITHAKALA")
NoA <- c(6,7,15,26,20,27,10,15,17,20,80,8,34,18,7,66,20,19,30,12)
NoV <- c(3,6,30,63,45,66,15,30,36,45,225,9,87,39,6,183,45,42,75,21)
for(m in 1:20){
a <- NoA[m]
b <- NoV[m]
for(j in 1:a){
for(i in 1:b){
print(paste0(Block[m],j,"_",i))
}
}
}
HTH
The code I suggested does the same thing as your R code. You never mentioned what form of output you wanted. If you want the same kind of output that you get from your R code, you simply have to add one more proc step, namely:
proc print data=want noobs;
var id;
run;
Art, CEO, AnalystFinder.com
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.