[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 8148 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 365 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
TPS Re-registration
What are your first memories of when Nepal Television Began?
निगुरो थाहा छ ??
ChatSansar.com Naya Nepal Chat
Basnet or Basnyat ??
NRN card pros and cons?
Sajha has turned into MAGATs nest
Toilet paper or water?
TPS EAD auto extended to June 2025 or just TPS?
Biden out, Trump next president, so what’s gonna happen to TPS, termination?
Nas and The Bokas: Coming to a Night Club near you
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
मन भित्र को पत्रै पत्र!
Will MAGA really start shooting people?
Democrats are so sure Trump will win
Tourist Visa - Seeking Suggestions and Guidance
From Trump “I will revoke TPS, and deport them back to their country.”
I hope all the fake Nepali refugee get deported
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
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