[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 8051 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 90 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
Toilet paper or water?
From Trump “I will revoke TPS, and deport them back to their country.”
Tourist Visa - Seeking Suggestions and Guidance
advanced parole
Sajha Poll: Who is your favorite Nepali actress?
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
Problems of Nepalese students in US
अरुणिमाले दोस्रो पोई भेट्टाइछिन्
Mamta kafle bhatt is still missing
Nepali Passport Renewal
seriously, when applying for tech jobs in TPS, what you guys say when they ask if you have green card?
Are Nepalese cheapstakes?
Nepali Psycho
MAGA denaturalization proposal!!
How to Retrieve a Copy of Domestic Violence Complaint???
wanna be ruled by stupid or an Idiot ?
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