BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi all,

I am a beginner on SAS and need your help.

I have a dataset consisting of 100 observations and 3 variables, where these three variables take a value of either 0 or 1 (they are binary). Suppose these three variables are v1, v2, and v3 respectively. I want to update my table considering the following conditions (where the column v4 has been created in advance):

For each single observation, I want to repeat the following action (beginning with the first one until the last observation):

Step1: Copy the row and paste it to the end of the table. If v1 is 0, assign 0 to v4 and jump to the next step. If v1 is 1, assign 1 to v4 and skip all the remaining steps (jump to the next observation).

Step2: Copy the row and paste it to the end of the table. If v2 is 0, assign 0 to v4 and jump to the next step. If v2 is 1, assign 1 to v4 and skip all the remaining steps (jump to the next observation).

Step3: Copy the row and paste it to the end of the table. If v3 is 0, assign 0 to v4 else assign 1 to v4. Jump to the next observation.

After the copy-paste operations, I also want to get rid off the first 100 rows (those rows which constitute the raw data).

I thank you in advance for your support. I hope that I did explain my problem explicitly.

Umut

Message was edited by: umutari Message was edited by: umutari
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
This task can be accomplished with DATA step programming in SAS. You have available to you (and it's free!) a vast amount of supplemental sample code, SAS-hosted DOC, and technical / conference topic material available to you at the SAS support http://support.sas.com/ website, in addition to the SAS discussion forum archives. Suggest you consider starting with the available SAS documentation, to build upon a SAS DATA step approach, adding IF / THEN ; logic, with INPUT statement to read up your file (if not already in SAS), and use OUTPUT statement logic as needed.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search arguments, this topic / post:

data step programming introduction site:sas.com

step by step programming site:sas.com

sas programming examples site:sas.com
syam_india_kochi
Calcite | Level 5
Hi,

As far as I understood you question, the below code may be helpful..

data outputtablename;
set inputtablename;
if (v1=0 or v2=0 or v3=0) then v4=0;
if (v1=1 or v2=1 or v3=1) then v4=1;
run;

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
  • 2 replies
  • 4042 views
  • 0 likes
  • 3 in conversation