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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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