[Show all top banners]

last_buddha
Replies to this thread:

More by last_buddha
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 HELP w/ SAS
[VIEWED 7065 TIMES]
SAVE! for ease of future access.
Posted on 03-30-15 2:48 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Hey Guys, 
I am trying to change the output of my rawdata file. In the rawdata, the output is in the following format

Name Test1 Test2 Test3 Test4
xyz 45 78 88 100
avb -1 89 76 29

But I want to change it to following format

Name Score
xyz 45
xyz 78
xyz 88
xyz 100
xyz 89 (skip -1 cuz it's less than0) 

I am trying to use array and output statement but having trouble. 
Can someone help? 

P.S. I uploaded a pic not sure if it worked.

Best, 
LB

 
Posted on 03-30-15 7:34 PM     [Snapshot: 70]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I don't have a SAS program to use right now but try something like this:


data try;
set yourdata; ******************** change the dataset name here;
array Tests[4] Test1-Test4;
do i =1 to 4;
if Tests(i) >=0 then do; **** this should exclude values with less than 0;
Score=Tests(i);
output;
end;
end;
keep name score;
run;

 
Posted on 03-30-15 8:11 PM     [Snapshot: 112]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Thank you very much. It worked.
LB
 
Posted on 03-30-15 9:41 PM     [Snapshot: 166]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Hey Arrogant,
Can I ask for little more help?
Following is my code for my hw.
I am trying to create a new variable called Grade as Pass or Fail but for some reason it is not working. Any idea how I can fix it?

dm "out;clear;log;clear";
option pageno=1;
title "Test Record";
%let path = C:\SAS\Hw 5;
libname sasdata "&path";
filename rawdata "&path\Testrecords.txt";
data work.records1;
Infile rawdata lrecl=100 pad;
Input ID Name $ Gender $ Height Weight DOB$ Test1 Test2 Test3 Test4 Test5 Test6 ;
run;
data records2;
set records1;
Array Test(*) Test1 Test2 Test3 Test4 Test5 Test6;
do i = 1 to 6;
If Test(i) gt -1 then do;
Score = test(i);
output;
end;
end;
Drop ID Gender Height Weight DOB i Test1 - Test6 ;
run;
proc contents;
run;
proc summary data = records2 nway missing;
class Name;
var Score;
output out = Score mean=;
run;
proc format;
value Grade
0 -< 70 = 'Fail'
70 - High = 'Pass'
run;
proc print;
format Score Grade.;
run;

 
Posted on 03-31-15 8:53 AM     [Snapshot: 276]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 
Posted on 04-03-15 9:57 AM     [Snapshot: 370]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

oops sorry didn't see the message earlier. Guess it's too late for your homework.

If you're just replacing the "Score" with the format you've create "Pass" or "Fail" then it should work fine. If you want to create a new variable called "Grade" and display as "pass" or "fail" after Score variable, then you'll have to create a new variable. Format will only replace the existing "score" variable. To create a new variable with the condition you can use "if then" statement.

Also, you have a missing semicolon in the proc format statement before run statement.

good luck.
 
Last edited: 03-Apr-15 10:03 AM

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 60 days
Recommended Popular Threads Controvertial Threads
What are your first memories of when Nepal Television Began?
निगुरो थाहा छ ??
Basnet or Basnyat ??
Sajha has turned into MAGATs nest
TPS Re-registration case still pending ..
Nas and The Bokas: Coming to a Night Club near you
मन भित्र को पत्रै पत्र!
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
TPS Work Permit/How long your took?
Breathe in. Breathe out.
Guess how many vaccines a one year old baby is given
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
चितवनको होस्टलमा १३ वर्षीया शालिन पोखरेल झुण्डिएको अवस्था - बलात्कार पछि हत्याको शंका - होस्टेलहरु असुरक्षित
शीर्षक जे पनि हुन सक्छ।
Travelling to Nepal - TPS AP- PASSPORT
Nepali doctors future black or white usa ?
Doctors dying suddenly or unexpectedly since the rollout of COVID-19 vaccines
Morning dharahara
Another Song Playing In My Mind
TPS Renewal Reregistration
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters