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
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.
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.
Thank you so much.
Finally, I succeeded to import the data with your help.
Have a good day!
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.