Greetings all. I need to create a 6500 unique account numbers for testing, 'ACCTNO0001' through 'ACCTNO6500'. I'm putting them into a one dimension array, but I can't figure out how to write the array to a dataset. I thought the write_array function would work, but I keep getting error message below. Is there a way to do this? All the example I found showed 2 dimension arrays, so maybe that is the problem? Thank you.
data _null_ ;
array accts[6500] $ ;
do i = 1 to 6500 ;
x = cat("ACCTNO",put(i,z4.)) ;
accts(i) = x ;
end ;
rc = write_array('work.accounts',accts) ;
run ; quit ;
ERROR 68-185: The function WRITE_ARRAY is unknown, or cannot be accessed.
ERROR: Illegal reference to the array accts.
Greg
Not really sure what you are trying to end up with. Do you want all of the data on one record or one each on 6500 records? The following would do the latter:
data work.accounts;
do _n_=1 to 6500;
ACCTNO=put(_n_,z4.);
output;
end ;
run;
Not really sure what you are trying to end up with. Do you want all of the data on one record or one each on 6500 records? The following would do the latter:
data work.accounts;
do _n_=1 to 6500;
ACCTNO=put(_n_,z4.);
output;
end ;
run;
Thank you Arthur, that is exactly what I wanted to do. I did not realize I could create a dataset on the fly using a loop. As usual, I made it harder than it needed to be.
Greg
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.