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

Hello everybody.

 

I would like to make 100 string variables card1-card100 so that card1=001... card10=010...card100=100.

Ideally a function that justifies right 'i' with '0' as fiiler character should be used. I tried right() but couldn't make it work.

 

What I then tried was

 

array card{100} card1-card100;
do i=1 to 100;
    if i in (1:9) then card{i}='00'||i;
    if i in (10:99) then card{i}='0'||i;
    if i=100 then card{i}='100';    
end;

but this won't work either.

 

Any ideas?

 

Thanks in advance.

 

P.S. I am on SAS 9.4

1 ACCEPTED SOLUTION

Accepted Solutions
Tim_SAS
Barite | Level 11
data;
array card{100} $3 card1-card100;
do i = 1 to 100;
    card{i} = put(i, z3.);
    put card{i};
end;
run;

View solution in original post

4 REPLIES 4
akotronis
Calcite | Level 5

Hi Tim.

 

I use

array card{100} card1-card100;
do i=1 to 100;
	card{i}=put(i,z3.);
end;

but it gives card1=1, card2=2, ..., card100=100, 

 

not card1=001, card2=002, ..., card100=100, 

Tim_SAS
Barite | Level 11
data;
array card{100} $3 card1-card100;
do i = 1 to 100;
    card{i} = put(i, z3.);
    put card{i};
end;
run;
akotronis
Calcite | Level 5

Thanks again Tim.

 

It even worked as

array card{100} $ card1-card100;
do i=1 to 100;
	card{i}=put(i,z3.);
end;

$ was the missing part..

 

Kind regards.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1355 views
  • 0 likes
  • 2 in conversation