Can you help me in the SAS code?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Can you help me in the SAS code?

The actual data could be find the attachment (DAT file)

The editor that I wrote:

DATA example;

INFILE 'C:\Users\nadzatul.abdullah\Documents\My SAS Files\9.3\example.dat';

INPUT Gender $1. +1 Race $1. +1 (Q1-Q120) (2.5);

RUN;

PROC PRINT DATA = example;

TITLE 'example';

RUN;

The output looks like this:

There are no output for Q1-Q13. How to extract the output so that they are exist in the table?

Hope that you guys able to help me to solve this problem.

Thank you so much Smiley Happy

                                                                                                                             

Attachment

Accepted Solutions
Solution
‎12-18-2012 11:16 PM
Frequent Contributor
Posts: 86

Re: Can you help me in the SAS code?

So, you have more than 13 rows of data in your input file and they are delimited by "TAB" I believe. To read them, you need to give right options in infile statement which is clearly specifiying the dlm ='<options>'.

In your case,

for Tab delimited file, it should be '09'x and dsd option  .

so, code would be:

data temp;

infile "D:\example.dat" dlm ='09'x dsd;

input x1 x2 x3 x4;

run;

Here, I just took only 1st four set of columns, you can include all of them and run.

View solution in original post


All Replies
Solution
‎12-18-2012 11:16 PM
Frequent Contributor
Posts: 86

Re: Can you help me in the SAS code?

So, you have more than 13 rows of data in your input file and they are delimited by "TAB" I believe. To read them, you need to give right options in infile statement which is clearly specifiying the dlm ='<options>'.

In your case,

for Tab delimited file, it should be '09'x and dsd option  .

so, code would be:

data temp;

infile "D:\example.dat" dlm ='09'x dsd;

input x1 x2 x3 x4;

run;

Here, I just took only 1st four set of columns, you can include all of them and run.

Occasional Contributor
Posts: 7

Re: Can you help me in the SAS code?

Thank you so much.

Finally, I succeeded to import the data with your help.

Have a good day!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 199 views
  • 0 likes
  • 2 in conversation