Dataset abc have 10 columns.
Dataset xyz have these 10 columns listed as rows repeating by primarykey(PK)
Need to fill the dataset abc's 10 columns with either 'Yes' (if the PK in xyz has it listed as an observation) or 'No' if not.
Ran the above pgm and got the below
SAS ERROR: The variable _name_ in the DROP, KEEP, or RENAME list has never been referenced.
Also, _name_ is in abc dataset but not in xyz.
Column names potentially in real scenario are not like col1, col2 but like abvcsd, sdkfjskd etc., Any better ways to handle this (apart from array declaration)?, please comment..
i don't know why, but please try the following instead
input pk _name_ $;
proc sql noprint;
select distinct _name_ into :columns separated by ' ' from xyz;
data abc(drop=i _name_);
$ 3 &columns;
call pokelong(repeat('No ', dim(cols)), addrlong(cols), 3*dim(cols));
set xyz(keep=pk _name_);
do i=1 to dim(cols);
if _name_ = vname(cols[ i ]) then cols[ i ] = 'Yes';
If it doesn't work, then this problem is beyond my capacity.
Also, a usage note. There is a HUGE warning in the documentation about the use of POKELONG, which I quote here in its entirety:
The CALL POKELONG routine is intended only for experienced programmers in specific cases. If you plan to use this routine, use extreme care both in your programming and in your typing. Writing directly into memory can cause devastating problems. It bypasses the normal safeguards that prevent you from destroying a vital element in your SAS session or in another piece of software that is active at the time."
My overall recommendation is that you read the documentation on ARRAY processing and on using FIRST. and LAST. by variable processing as well as some Macro processing basics. One possible alternate approach is shown below.