0

Thanks user667489. Perhaps I think good.. But now I have problem with merge methods...

data Dictionary;
   input id_wiersz Labely $20. ;
   datalines;                      
1 Active
2 Gold
3 Prime
;

*Get the array parameter;
proc sql noprint;
select count(1) into :reccount from work.Dictionary ;
quit;

proc transpose data = Dictionary out = Dictionaryout;
    var Labely;
run;

data ArraryLoaded;
    set Dictionaryout (drop=_name_) nobs = nobs;
    array Dictionary _CHAR_;
    format col1-col3 $50.;
    retain col1-col3;
    array t[&reccount] $;
    do i = 1 to dim(t);
        if _N_ = 1 then t[i] = put(Dictionary[i], 8.);
            else t[i] = compress(t[i] || ',' || put(Dictionary[i], 8.));
    end;
    if _N_ = nobs;
    put "var1," t1;
    put "var2," t2;
    put "var3," t3;
run;

data Scinamy;
   input Description $20. ;
   datalines;                      
New old Active
New Active Old
ANother record
Records with Gold
Value with Gold
;

How to lista(&reccount) insert array t[&reccount]?

data Scinamy1;
  set Scinamy;
  array lista(&reccount) $8 _temporary_ ('Active','Gold','Prime');
  length AA $30 ;
  do i = 1 to dim(lista);
    if findw(Description,lista(i),,'spit') then AA=catx(' ',AA,lista(i));
  end;
  if missing(AA) then AA='Not Found';
  drop i;
run;
2
  • What is the question? Commented Jun 20, 2018 at 17:19
  • Hey Tom, In step "data ArraryLoaded"'I loaded values to array from table. And I need use this array to next step - data Scinamy1; - i want use array from Data ArraryLoaded instead "array lista(&reccount) $8 _temporary_ ('Active','Gold','Prime'); from data Scinamy1; Commented Jun 21, 2018 at 7:02

2 Answers 2

1

I can think of a few options that you could explore:

  1. Replace each distinct value of Labely with a different integer and define a format to display the corresponding values. Then you can use your existing write_array approach.
  2. Define and populate a character array within a data step using a do-loop.
  3. Use a hash object to hold your dictionary instead of an array, and loop through it using a hash iterator.

Have a go at one of these and post another question if you get stuck.

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to use the data from your small table to generate a temporary array in a future data step you could use the SAS macro processor to help you generate the statement.

If the list is small enough to fit into a single macro variable (64K characters) then you could use something like this:

proc sql noprint;
  select quote(trim(LabelY)) into :Label_list separated by ' '
  from work.dictionary;
%let no_labels=&sqlobs;
quit;

data new_step ;
   array lista(&no_labels) $20 _temporary_ (&label_list) ;
....

Watch out because dictionary is a special libref in PROC SQL. Prefixing with work. should make it work. Or just name the dataset something else.

But it might just be easier to use the original dataset instead of an ARRAY.

data Scinamy1;
  set Scinamy;
  length AA $30 ;
  do i = 1 to nobs;
    set work.dictionary(keep=LabelY) point=i nobs=nobs;
    if findw(Description,LabelY,,'spit') then AA=catx(' ',AA,LabelY);
  end;
  if missing(AA) then AA='Not Found';
  drop LabelY ;
run;

1 Comment

Excellent! Both methods works great, and I understood two new methods processing :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.