SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hkirk
Fluorite | Level 6

Hi! I'm working with the SAMHSA TEDS data set using CIMPORT. I used the recommended infile code:

 

proc cimport

infile= "C: \......\TEDS_2022.stc"lib=WORK;

Run;

But the variables are not populating in the table. I imported the coded variable library they provided but it's qualitative and I would rather work with the raw quanitative data that comes with the original imported file. You can get it through the .csv but it's so large I fear it may be incomplete. Is there a recommeded code I can use after the import to make sure the variables are recogized? I tried the libname= my lib and tranfile steps but they don't seem to work with .stc files. Any help is appreciated.

Thx

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If you are talking about this page

https://www.samhsa.gov/data/data-we-collect/teds/datafiles

(or perhaps some other year done in the same style) then I suspect that this issue is that you did not define the FORMATS that it has attached to the variables.

 

They included a .SAS file with the format definitions in the ZIP file.

Either set the system option NOFMTERR so that the Viewtable widget can open the dataset and SAS code can open the dataset.

options nofmterr ;

Or remove the formats from the variables.  Either in an individual step.

proc print data=TEDSA_PUF_2022(obs=3) width=min;
  format _all_ ;
run;

Or in a DATA step or PROC DATASETS step.

 

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

I am not sure what you mean by

But the variables are not populating in the table.

Did the PROC CIMPORT step run or not?

How many datasets did it find in the .stc file?

What where their names?

What variables did they contain?

 

What do you mean by the word "table"?  Do you mean a SAS dataset? Or did you run a program to produce a report? If the later what code did you try to run and what information where you trying to report on?

 

hkirk
Fluorite | Level 6

It looks like the PROC CIMPORT STEP ran because it created a result viewtable in the work folder in the library. However when I try to open it, I get an error message saying it "cannot be opened". I then ran a PROC CONTENTS and it generated the list of variable names and values no problem. But won't populate the table in the results. If I import the library code, it populates the table in the viewtable, but it's coded to convert all the numeric data into qualitative data, I would rather it stay quant. It's just easier to program around and manipulate. This is data collected from a government survey with categorical and numeric variables. I haven't been able to find a lot out there on working with .sct files. 

Tom
Super User Tom
Super User

If you are talking about this page

https://www.samhsa.gov/data/data-we-collect/teds/datafiles

(or perhaps some other year done in the same style) then I suspect that this issue is that you did not define the FORMATS that it has attached to the variables.

 

They included a .SAS file with the format definitions in the ZIP file.

Either set the system option NOFMTERR so that the Viewtable widget can open the dataset and SAS code can open the dataset.

options nofmterr ;

Or remove the formats from the variables.  Either in an individual step.

proc print data=TEDSA_PUF_2022(obs=3) width=min;
  format _all_ ;
run;

Or in a DATA step or PROC DATASETS step.

 

hkirk
Fluorite | Level 6

BRILLIANT! Thank you so much! I knew I was missing something obvious. Thanks!

Ksharp
Super User
Adding the following options before proc cimport:

option validvarname=any validmemname=extend nofmterr;
proc cimport
.......

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2803 views
  • 4 likes
  • 3 in conversation