Hello everyone,
I found a SAS document related to VIEW then I executed in my SAS EG locale. I think It needs to be 5 rows instead of 4 rows but I couldn’t see the the row which begins with frisbee. On the other hand, my another question is how to take student.txt file as following image, how should I separate it when import to EG. Does anyone here can show me with screenshot ? If you show me over student.txt file so much the better.
libname myv9lib 'C:\Try';
filename student 'C:\Try\student.txt';
data myv9lib.class(keep=name major credits)
myv9lib.problems(keep=code date) / view=myv9lib.class;
infile student;
input name $ 1-10 major $ 12-14 credits 16-18;
select;
when (name=' ' or major=' ' or credits=.)
do code=01;
date=datetime();
output myv9lib.problems;
end;
when (0<credits<90)
do code=02;
date=datetime();
output myv9lib.problems;
end;
otherwise
output myv9lib.class;
end;
run;
proc print data=myv9lib.class;
run;
proc print data=myv9lib.problems;
format date datetime18.;
run;
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001278887.htm
Thanks
Hi,
Your every thing perfect except "Missover" option missed in your Infile statement.
Try It... I got the results as you expected.
First Question:
data myv9lib.class1(keep=name major credits)
myv9lib.problems1(keep=code date) / view=myv9lib.class1;
infile student missover;
input name $ 1-10 major $ 12-14 credits 16-18;
select;
when (name=' ' or major=' ' or credits=.)
do code=01;
date=datetime();
output myv9lib.problems1;
end;
when (0<credits<90)
do code=02;
date=datetime();
output myv9lib.problems1;
end;
otherwise
output myv9lib.class1;
end;
run;
proc print data=myv9lib.class1;
run;
proc print data=myv9lib.problems1;
format date datetime18.;
run;
Second Question:
data class(keep=name major credits);
infile student missover;
input name $ 1-10 major $ 12-14 credits 16-18;
run;
Thanks & Regards,
Bharath
Hi,
Your every thing perfect except "Missover" option missed in your Infile statement.
Try It... I got the results as you expected.
First Question:
data myv9lib.class1(keep=name major credits)
myv9lib.problems1(keep=code date) / view=myv9lib.class1;
infile student missover;
input name $ 1-10 major $ 12-14 credits 16-18;
select;
when (name=' ' or major=' ' or credits=.)
do code=01;
date=datetime();
output myv9lib.problems1;
end;
when (0<credits<90)
do code=02;
date=datetime();
output myv9lib.problems1;
end;
otherwise
output myv9lib.class1;
end;
run;
proc print data=myv9lib.class1;
run;
proc print data=myv9lib.problems1;
format date datetime18.;
run;
Second Question:
data class(keep=name major credits);
infile student missover;
input name $ 1-10 major $ 12-14 credits 16-18;
run;
Thanks & Regards,
Bharath
Hello ,
Thank you for your help. About my second question, I have to say that, I want to see an image while we import the file from .txt to EG to understand better.I shared a image as below. I’m not sure what should I do in the following image to get the data set as my previous message's image.
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a002645812.htm
About the MISSOVER option, I found a website link. Actually, I nearly understood the option but by default how data reads to raw data from .txt ? How did the following output happen? In spite of following writing I couldn’t properly get it.
The DATA step reads the first value (22). Because the value is shorter than the 5 characters expected by the informat,(This part is ok.) the DATA step attempts to finish filling the value with the next record (333).(Why 333 ??? It is also shorter than the 5 characters )This value is entered into the PDV and becomes the value of the TestNumber variable for the first observation.
Thank you.
Hello @Reeza,
Happy new year to you. I've already tried fixed selection but I couldn't get it.I put a image as below. What should I write now ? It is not necessary but I just want to learn it. Can you lead me over the image, please ?
Thank you.
Hello @Reeza,
I've actually tried 18 also I put a image as below it includes the screen after I wrote 18 in "Fixed Colum" textbox. Do you have a chance to try the srudent.txt ? But it is not necessarily .Thanks though.
The columns are of fixed length but they are not all of the same length so you can't just set a value of 18 or 20.
As shown below the EG import wizard lets you set different lengths simply by clicking on the right position in the preview grid. This will result in the correct SAS code being generated. See example below
Hello @Patrick,
When I selected the "Fixed Colum" radio button last time "Record Length" was enable. Now the "Record Length" is unable. I don't understand the reason. Thank you for your help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.