I am working on something right now and I am stuck.. can anyone help me??
Data set Errors contains character variables Subj (3 bytes) and PartNumber (8 bytes). create a temporary SAS data set (Check1) with any observations in Errors that violates either of the following two rules: first, Subj should contain only digits, and second PartNumber should contain only the upper case letters L and S and the Digits.
it gives you a set of Datalines which are
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
My Solution isn't working
data a15009.errors;
input subj
PartsNumber
Name
;
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
run;
Proc Print data = a15009.errors;
Run;
Please Help!!
@randythomas84 wrote:
My Solution isn't working
Can you post your non-working solution so we can see what approach you're taking?
@randythomas84 wrote:
I am working on something right now and I am stuck.. can anyone help me??
Data set Errors contains character variables Subj (3 bytes) and PartNumber (8 bytes). create a temporary SAS data set (Check1) with any observations in Errors that violates either of the following two rules: first, Subj should contain only digits, and second PartNumber should contain only the upper case letters L and S and the Digits.it gives you a set of Datalines which are
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
My Solution isn't workingdata a15009.errors;
input subj
PartsNumber
Name
;
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
run;
Proc Print data = a15009.errors;
Run;Please Help!!
This is my solution it just puts periods in the boxes instead of any names
data errors;
input subj
PartsNumber
Name
;
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
run;
data correct;
infile cards truncover;
input subj $
PartsNumber $
Name & $20.
;
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
run;
It is still just giving periods instead of giving me the errors and correcting them.
As I read it it should display everything with corrections correct?
@randythomas84 Try applying the conditions listed in the question with an if then statement after the input statement.
Please attempt. Trust me you will get the hang of it
for a start if anyalpha(subj)>0 or notdigit(subj)>0 will indicate presence of chars other than digits. My request is for you to try and come back to community to make the discussion more interesting and interactive please
@novinosrin I would love too only i'm just starting to use SAS and I have no clue what I'm doing still.. I'm sorry I really don't I'm working on it but the syntax is a little weird to me.
meddle with this code and change the conditions as necessary:
data errors correct all;
infile cards truncover;
input subj $
PartsNumber $
Name & $20.;
if anyalpha(subj)>0 or length(compress(partsnumber,'LS','n'))>0 then output errors;
else output correct;
output all;
;
datalines;
001 L1232 Nichole Brown
0a2 L887X Fred Beans
003 12321 Alfred 2 Nice
004 abcde Mary Bumpers
x89 8888S Gill Sandford
;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.