BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
najiah
Calcite | Level 5

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

                                                                                                                             

1 ACCEPTED SOLUTION

Accepted Solutions
bnarang
Calcite | Level 5

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

2 REPLIES 2
bnarang
Calcite | Level 5

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.

najiah
Calcite | Level 5

Thank you so much.

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

Have a good day!

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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