BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gsnidow
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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;


View solution in original post

2 REPLIES 2
art297
Opal | Level 21

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;


gsnidow
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1493 views
  • 2 likes
  • 2 in conversation