data want; call streaminit(27182818); do _n_=1 to 1000; p1=rand('integer',n1); set firstnames nobs=n1 point=p1; p2=rand('integer', n2); set lastnames nobs=n2 point=p2; p3=rand('integer', n3); set cities nobs=n3 point=p3; r=ranuni(31416); output; end; run;
So, I tired running the following modified code. I modified the code because the original code gave me an output data set with 2 million obs and all my variables, but my first_name column had the same value repeating. It turned out to be the first value in the firstnames input dataset. In order to get random values in all my columns i ran the following code, but SAS was not able to fully execute because of insufficent data. It turned out that it stopped processing after 4 million + obs instead of stopping at 2 million. If anyone could offer a possible solution. Thank you!
You need a STOP statement between END; and RUN; All of the data access is now with POINT and there if end-of-file set when reading with POINT as you usually have with regular set. See documentation for exact details. In other words the implied data step loop has not way to stop itself.
@juanvenegas wrote:
data want; call streaminit(27182818); do _n_=1 to 1000; p1=rand('integer',n1); set firstnames nobs=n1 point=p1; p2=rand('integer', n2); set lastnames nobs=n2 point=p2; p3=rand('integer', n3); set cities nobs=n3 point=p3; r=ranuni(31416); output; end; run;So, I tired running the following modified code. I modified the code because the original code gave me an output data set with 2 million obs and all my variables, but my first_name column had the same value repeating. It turned out to be the first value in the firstnames input dataset. In order to get random values in all my columns i ran the following code, but SAS was not able to fully execute because of insufficent data. It turned out that it stopped processing after 4 million + obs instead of stopping at 2 million. If anyone could offer a possible solution. Thank you!
@juanvenegas wrote:I modified the code because the original code gave me an output data set with 2 million obs and all my variables, but my first_name column had the same value repeating. It turned out to be the first value in the firstnames input dataset.
Is it possible that you were misled by looking at only the first few observations before sorting by random number r? In this case, indeed, you'd have seen the first first name multiple times (in fact 1000 times with the do _n_=1 to 1000 loop) -- but this is correct because the 1001th through 2000th obs. would contain the second first name and so on until the 1,999,001th through 2,000,000th obs. with the 2000th first name (hence all first names used, as intended: 2000 first names, each with 1000 observations). The random sort order would be achieved by the final PROC SORT step (BY r).
this is possible. I only scrolled through the first couple hundred obs.
data want; call streaminit(27182818); set firstnames; do _n_=1 to 1000; p1=rand('integer',n1); set firstnames nobs=n1 point=p1; p2=rand('integer', n2); set lastnames nobs=n2 point=p2; p3=rand('integer', n3); set cities nobs=n3 point=p3; output; end; run;
This worked!!! Thanks everyone!
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: