BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Hello,

I need help in changing the first and 8th observation of my data, while leaving the rest unchanged.
using a simple
if obs=1 then s=1 s2=1 s3=1;
run;
does not work
6 REPLIES 6
RickM
Fluorite | Level 6
It should be :


if _N_=1 or _N_=8 then s=1 s2=1 s3=1;
run;

Good luck!
R_A_G_
Calcite | Level 5
thanks but it gives me the following error:

NOTE: Line generated by the invoked macro "MISQMATRIX".
1 data QMatrix; set Q_MATRIX_WR; IF _N_=1 or _N_=8 THEN skills1=1 skills2=1 skills3=1; run;

-------
-------

22
22

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, ;, <, <=,
<>, =, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=,
|, ||, ~=.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.QMATRIX may be incomplete. When this step was stopped there were 0
observations and 4 variables.
WARNING: Data set WORK.QMATRIX was not replaced because this step was stopped.
RickM
Fluorite | Level 6
Sorry about that, you also need to use do;

data QMatrix;
set Q_MATRIX_WR;
IF _N_=1 or _N_=8 THEN do;
skills1=1;
skills2=1;
skills3=1;
end;
run;
Tim_SAS
Barite | Level 11
[pre]
if _N_ = 1 or _N_ = 8 then do;
skills1=1;
skills2=1;
skills3=1;
end;
[/pre]
R_A_G_
Calcite | Level 5
Thank you Rick and Tim it WORKED!
R.A.G.
advoss
Quartz | Level 8
Or
if _N_ in (1,8) then do;
skills1=1;
skills2=1;
skills3=1;
end;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1436 views
  • 0 likes
  • 4 in conversation